Reputation: 1554
How to find directories that do not contain files last accessed within 1 day and tar them under the shell? i.e:
./
directory1/
directory2/directory3/directory/file3
directory3/directory6/file5
if file3 has been accessed within 1 day then after the execution of the script i would like that:
./directory1.tgz
./directory3/directory6.tgz
Upvotes: 1
Views: 134
Reputation: 26511
I tried hard to come up with a single big find
command, but here is a little shell instead:
for i in ./*
do
test -d "$i" || continue
test -z "$(find "$i" -type f -atime -1)" || continue
tar zcf "$i".tgz "$i"
done
Upvotes: 1