Want to 7zip all files in root/current folder except for all zip-files AND all 7z/7zip files. I can only get one of these to work at a time in one if ! statement:
for file in ./test2/* do if ! { `file $file | grep -i zip > /dev/null 2>&1` && `file $file | grep -i 7z > /dev/null 2>&1`; }; then ## Most of the zip utilities contain "zip" when checked for file type. ## grep for the expression that matches your case 7z a -mx0 -mmt2 -tzip "${file%/}.cbz" "$file" rm -rf "$file" fi done I have followed the "list" {list;}; standards from other posts, but no luck.
My current solution is to nest if statements, like so:
for file in ./test2/* do if ! `file $file | grep -i 7z > /dev/null 2>&1`; then if ! `file $file | grep -i zip > /dev/null 2>&1`; then ## first if its not 7z, now also if not zip. 7z a -mx0 -mmt2 -tzip "${file%/}.cbz" "$file" rm -rf "$file" fi fi done Only thing left is exclude directories. All files go. How to?