I'm trying to do the following within a for
loop:
- Find files that satisfy a condition
- Echo the name of the files to a log file.
- Gzip the file.
I can get the script to find the files and echo their names to the screen but cannot pipe them to a file. (I have not got as far testing the gzip part)
Here's the relevant portion of the script (The $LOGCLEAN_FILE
exists and is written to in an earlier portion of the script):
for F in `find . -type f \( ! -name '*.gz' \) -a \( ! -name '*.Z' \) -mtime +7`
do
{
print "Will be compressing file ${F}" >> $LOGCLEAN_FILE
} ;
##gzip $F
done
If I run the script without the " >> $LOGCLEAN_FILE"
text then the output displays on the screen.
What am I doing wrong?
Criticisms are welcome - I'm still learning.
echo
, notprint
. – vonbrand Mar 15 '13 at 19:05print
in the shell that morgon specified (ksh
). – Stéphane Chazelas Mar 15 '13 at 20:44$LOGCLEAN_FILE
? If it's a relative path, have you changed directories? – Gilles 'SO- stop being evil' Mar 15 '13 at 22:13