Hi,
I need help in regard to developing a shell script to delete empty files from multiple specific locations. The directory paths will be stored in a text file. So the requirement is to read the text file for one specific path and then remove empty files from that particular path. Looping through till end of the text file where path locations are defined.
Any template to meet this requirement will be greatly appreciated.
Contents of the file where multiple specified paths will be mentioned:
vim pathfile.txt
/d02/apps/output/UAT/CMFUP/reports
while IFS='' read -r path;
do
name="$path"
echo "Finding Empty Files from location - $name"
find $name -empty -print
done < "$1"
ran by executing
./CM_Del_Emp_files.sh pathfile.txt
Results in ERROR:
sysadm@xxxh016:[UAT:NRDP]:/d01/apps/ccb/UAT/scripts/cm> ./CM_Del_Emp_files.sh pathfile.txt
Finding Empty Files from location - /d02/apps/ccboutput/UAT/CMFUP/reports
find: `/d02/apps/output/UAT/CMFUP/reports\r': No such file or directory
It looks like the editor you used to create pathfile.txt was set up to use DOS (<carriage-return><newline> character pair) line terminators instead of UNIX (<newline> single character) line terminators. The extra <carriage-return> character at the end of the line is being interpreted as part of the pathname of the file; not as part of the line terminator.