find files in date range
ls -l /tmp/empty_file*
-rw-r--r-- 1 root root 0 2010-05-30 08:00 /tmp/empty_file -rw-r--r-- 1 root root 0 2010-05-30 12:00 /tmp/empty_file1 This looks good, the files expected to be seen are output: find /usr \( -newer /tmp/empty_file -a \! -newer /tmp/empty_file1 \) -print But this shows me files that should not be output and likewise when I replace ls with tar it is tarring a whole bunch of stuff I do not want: find /usr \( -newer /tmp/empty_file -a \! -newer /tmp/empty_file1 \) -exec ls -l {} \; In the end I would like to replace the "ls" with "tar cvvfp some.tar {} \;", but can't figure out what is going wrong here. |
Quote:
In any case you may want to limit the results to files and exclude directories, otherwise the tar command will archive the entire content of the directories (despite the timestamp of the files inside). Moreover, take in mind that -exec executes the command multiple times, each one over each line of input (that is over each object found). Typically the tar command is used over a bunch of files all together, hence better to pipe the output to xargs, like in Code:
find /usr -type f \( -newer /tmp/empty_file -a \! -newer /tmp/empty_file1 \) -print0 | xargs -0 tar cvvpf some.tar |
Solved: find files in date range
Thank You, you nailed what exec was doing "tar command will archive the entire content of the directories". The following is working for me:
find /usr \( -newer /tmp/empty_file -a \! -newer /tmp/empty_file1 \) -type f |xargs tar cvf new.tar |
All times are GMT -5. The time now is 07:47 PM. |