On Mon, Jan 26, 2009 at 9:28 PM, Mr O <[email protected]> wrote:
> ls -ltr shows creation date from oldest to newest but can I narrow that down
> and say only print the last 30 days changes? What about a recursive search?
> How about a variable showing only the last 14 days or 7 days? How about
> narrowing down to a specific date after finding what was needed?
Use find instead of ls:
# all files, recursively, created within the past 30 days
find . -ctime -30
Naturally, 'man find' will be of great help. :)
> Next, could I take that output and drop it on the command line so I can then
> mv, rm, cp, or more to those files only?
There are several ways to do this:
# remove files created within the past seven days
find . -ctime -7 | xargs rm
find . -ctime -7 -exec rm \{} ; # my least favorite way
For anything more complicated than a single statement, I prefer a for loop:
for file in `find . -ctime -7`; do
cp ${file} /somplace/
ln -s /someplace/${file} /someplace/else/${file}
done
HTH!
Chris St. Pierre
_______________________________________________
EUGLUG mailing list
[email protected]
http://www.euglug.org/mailman/listinfo/euglug