Listing files of PAST 7 days and concatenate it...

Hi All,

I want to list file of LAST 7 days acc. to its modified date and then concatinate.

I have following piece of code..
For concatenate

cat file1 file2 >> Output (For concatinating)
find . -mtime -7 -exec basename {} \;  (list past files but it is including . file also)

Plz help how to arrange it....
date -d '7 days ago (this function is not working on my OS)

You can do that all in one line, I'll show it step by step:

First, limit the search only to files, so directories like "." don't show up:

find . -mtime -7 -type f -exec basename {} \;

Print the found files names:

find . -mtime -7 -type f -print

Then do something with the files instead of just giving the name:

find . -mtime -7 -type f  -print -exec cat {} >> /some/output/file \;

Be sure to concatenate the files in a location other than where you search, because otherwise the new file will become concatenated to itself (which is very bad mojo for files).

I hope this helps.

bakunin

try this ..

$ find . -type f -mtime -7 -exec cat {} > 7dayfilecontent \; 2>/dev/null

This will overwrite the content of "7dayfilecontent" over and over again. Further the error channel is not there to be thrown away but to be observed - if something shows up there then probably so for a reason. Unless you don't know for sure you don't need it you shouldn't do that.

baknin

thanks for help...
how do I get files for concatinating