Greetings all,
I am calling a remove from within a script that is used for a cleanup process.. It is not working as expected. Here is what I am doing.
I have a config file that lists out a directory name, and the options to run
Within the config file
DIR1="find /directory/holding"
DIR1OPTIONS="-type f ! -name \"*.gz\" ! -name "*PDF*" ! -name \"*TIF*\" -size +1000k -mmin +120 -exec gzip {}+"
I have another script that I am scheduling via an external tool to run- Simple.
#!/bin/ksh
#Script Below#
#Add additional lines to config options.
. ./prune.config
$DIR1 $DIR1OPTIONS
It is not working. I am getting the below error-
find: incomplete statement
I threw an echo statement under the script that runs and I am getting the output, it looks correct. If I copy it and then run it, it works.
I suspect something is up with the config file. Any suggestions
try this:
DIR1OPTIONS='-type f ! -name "*.gz" ! -name "*PDF*" ! -name "*TIF*" -size +1000k -mmin +120 -exec gzip {}+'
Looks like the echo stays the same. I was trying to escape the items identified in -name.
[me@server:/me/scripts]> ./prune.ksh
find: incomplete statement
find /directory/holding -type f ! -name "*.gz" ! -name "*PDF*" ! -name "*TIF*" -size +1000k -mmin +120 -exec gzip {}+
Hi,
Try this:
find /directory/holding -type f ! -name "*.gz" ! -name "*PDF*" ! -name "*TIF*" -size +1000k -mmin +120 -exec gzip {}+ \;
The final \;
for the exec clause is mandatory. I don't know why you add the plus sign to the filename : {}+
.
Try
-exec gzip {} \;
.
Regards.
Same result.
[me@server:/me/scripts]> ./prune.ksh
find: incomplete statement
find /directory/holding -type f ! -name *.gz ! -name *PDF* ! -name *TIF* -size +1000k -mmin +120 -exec gzip {} \;
The following may help:
ksh -x ./prune.ksh
So we can see how is parsed the statement.
Regards.
[me@server:/me/scripts]> ksh -x ./prune.ksh
+ . ./prune.config
+ + date +%OY%Om%Od
TIMESTAMP=20170515
+ DIR1=find /directory/holding
+ DIR1OPTIONS=-type f ! -name "*.gz" ! -name "*PDF*" ! -name "*TIF*" -size +1000k -mmin +120 -exec gzip {} \;
+ find /directory/holding -type f ! -name "*.gz" ! -name "*PDF*" ! -name "*TIF*" -size +1000k -mmin +120 -exec gzip {} \;
find: incomplete statement
+ echo find /directory/holding -type f ! -name "*.gz" ! -name "*PDF*" ! -name "*TIF*" -size +1000k -mmin +120 -exec gzip {} \;
find /directory/holding -type f ! -name "*.gz" ! -name "*PDF*" ! -name "*TIF*" -size +1000k -mmin +120 -exec gzip {} \;
This script work fine in my computer:
#!/bin/ksh
#Script Below#
#Add additional lines to config options.
. ./prune.config
eval "$DIR1 $DIR1OPTIONS"
Regards.
---------- Post updated at 05:25 PM ---------- Previous update was at 04:12 PM ----------
This also work fine:
DIR1="find /directory/holding"
DIR1OPTIONS="-type f ! -name \"*.gz\" ! -name "*PDF*" ! -name \"*TIF*\" -size +1000k -mmin +120 -exec gzip {} ;"
$DIR1 $DIR1OPTIONS
(Without the backslash before the semi colon).
Regards.
RudiC
9
Not necessarily. man find
(on my linux: find (GNU findutils) 4.7.0-git)
But: a space before the +
may be compulsory.
Yes, it's true. The problem was the lack of a space between {}
and +
.
Regards.