A program to solve a problem: filter Linux/Unix 'ls' output
#2
Hi @TDarcos

Clever program.

Did you know you can actually use find command in linux and either pass the results to xargs or use the -exec method to do something ?

Find all files modified since the the last year (run from root directory of where you are scanning):

Code: (Select All)
find . -mtime +365 -print
You could then simply do: 
Code: (Select All)
find . -mtime +365 -exec cp {} destination/dir/{} \;
For every file created or modified since this year (365 days) execute the command:
Code: (Select All)
cp (foundfile) destination/dir/(foundfile)
The funky syntax for the -exec arg simply replaces {} with the found file, and the \; let's you terminate the -exec command. The backslash is to escape the ; in the shell.

Your program is cool too, not saying to not use it. Also it's lots of fun to solve our own problems!

I just wanted to share this 1 liner since i've used it so much in my life. The linux find command is a life saver.

Check out the docs:
Code: (Select All)
man find
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply


Messages In This Thread
RE: A program to solve a problem: filter Linux/Unix 'ls' output - by grymmjack - 07-15-2023, 12:29 AM



Users browsing this thread: 3 Guest(s)