I am trying to take filenames with spaces Get them into a for loop zip each file Once zipped, remove the original using below:
for appdir in $(ls /home/location/$dirname); do
for logFile in $(find /home/location/$dirname/$appdir -type f -mtime +10 \( ! -iname "*.zip" ! -iname "*.gz" \)); do
echo $logFile
Files I am trying to zip which has spaces:
/home/location/hdd1/domain/servername/EXT1/ET SOME To FILENAME/xml/sdlfkd.xml
/home/location/hdd1/domain/servername/EXT1/ET SOME To FILENAME2/xml/sd2fkd.xml
I know filenames with spaces can be made into a single filename like below -
find /location/$appdir -type f -mtime +10 -print0 | xargs -0 ls
The actual zip command which takes the filename from the "for" condition comes later to take each file, makes a zip and removes the original one.
I get below error for zip command:
[stdout: 4] zip warning: name not matched: ET
zip error: Nothing to do! (ET.zip)
[stdout: 4] SOME
[stdout: 4] zip warning: name not matched: SOME
zip error: Nothing to do! (SOME.zip)
How can I modify the condition where I can provide entire filename each time to the "for" loop so it then proceeds to zip each file and goes further? Any help would be appreciated.