I want to compress (tar
or gzip
or zip
) directories older than two days. I have the files below. Each directory will have multiple subdirectories and files.
Oct 21 13:01 test1
Oct 22 13:01 test2
Desired output:
test1.tar
test2.tar
I tried writing the command, below; but, it is not working.
find . -type d -maxdepth 1 -mtime +2 \! -name '*.gz' -exec gzip {} \;
I am getting the below error.
gzip:test1.tar is a directory -- ignored
gzip:test2.tar is a directory -- ignored
find $dir -maxdepth 1 -type d -mtime -2
echo "$j" for i in "$j" do [ -d "$i" ] && zip -r "$i.zip" "$i" done – Naresh Oct 23 '17 at 15:28