I have multiple directories like below and I want to compress each file in place.
/var/dir1/logs/logfile.log
/var/dir2/logs/logfile.log
/var/dir3/logs/logfile.log
I want to use find
and tar
with combine but I don't know how to use the file name and path as variables.
This command zips all files in the one file:
find /dir/to/search/ -name "*.log" -exec tar -rvf out.tar {} \;