I want to search for files by the exact date and then execute tar command on the results files.
Example:
-rw-rw-r-- 1 0 Dec 4 08:07 file-1
-rw-rw-r-- 1 0 Dec 4 08:07 file-2
-rw-rw-r-- 1 0 Dec 5 08:07 file-3
I want to get only files with Dec 4 date and passing them to the tar command.
The archive should contain:
tar -ztvf dec4.tar.gz
Output:
-rw-rw-r-- 1 0 Dec 4 08:07 file-1
-rw-rw-r-- 1 0 Dec 4 08:07 file-2
This is my script it is still copying those Dec 5.
ls -ltr ./ | grep "Dec 4" | tar -zcvf /home/backupfiles_$(date '+%Y_%m_%d' --date='1 days ago').tar.gz