I am creating a script that is going to scan the contents of a directory, and if it finds a certain DocumentName that is a certain size (The example, DocumentName and a size of 8777)
If this file exists, it needs to be moved to a directory for later removal/processing..anyone have insight on this?
ls -l /Directory/subdirectory/DocumentName.*.Business.Qualifier.Status.pdf awk '{
if ($5 = 8777) { print "mv " $7 " /Directory/forremoval" }}
}'
find /Directory/sub/files/1/pdf -type f -name "branch.*.business.*.PDF.status" -size 1111 | while read name
do
fname=`basename $name | sed 's/\(.*\)\..*/\1/'`
touch $name /garbage_collector
done
Looking for the branch.business.*(Some kind of time stamp).pdf.status
if it finds that file name, that is 1111 bytes, move it to the /garbage_collector directory. It is still not working for me.
I need indicate 'units of space' in the '-size' parameter, see my example with no output in the first command and the correct file in the second. I hope it helps.
Thank you for the feedback. Here's where I'm at now.
find /Directory/subdirectory/-type f -name "Business.*" -size 1111c -print
I issue this in the home/userid directory, and it displays the full file name located in the /Directory/subdirectory folder. The next step, is moving the file if it found. Can I have help with that?
Next bash script works in my system. It moves file 'script.sed' to the previous directory in the tree. The '-v' parameter of 'mv' is verbose, to show what moves from one directory to another. Adapt it to your situation: