I am looking for files of a certian type and logging them. After they are logged they need to be moved to a different directory. HOw can i incorporate that in my current script?
i am not quiet sure about your req.
Suppose it is very close to follow:
Hint: Find all the .txt file in current directory, record them in file.log file and then copy them to the parent directory.
Hope you can finish it according to your exact requirements.
code:
for i in `find . -name \*.txt`
do
echo $i >> file.log
cp $i ../
done
Now, I need to modify this script to also use the output of the same find command as a list of files that need to be moved.
The CSV file does not need to be moved, later in the script I FTP it to another server where the results are parsed and each time this script is run, it is overwritten anyway.
Put in place the lost "-a" operator for combining the last 2 "-exec". It most likely got lost in the copy & paste operation. You can tweak it for your environment...
CSV_OUTFILE="somefile.csv"
find . -type f -name W\* \( -exec echo {} \; > ${CSV_OUTFILE} -a -exec cp {} /new_dir/ \; -a -exec rm {} \; \)