Anybody has an alternate way of finding and copying files in bash than:
find . -ctime -15 | awk '{print "cp " $1 " ../otherfolder/"}' | sh
I like this way because it's flexible, as I'm building my command (can by any command) and executing it after.
Are there other ways of streamlining commands to a list of files?
Thanks
To copy files and directories use the cp command under a Linux, UNIX-like, and BSD like operating systems. cp is the command entered in a Unix and Linux shell to copy a file from one place to another, possibly on a different filesystem.
Copy a File ( cp ) You can also copy a specific file to a new directory using the command cp followed by the name of the file you want to copy and the name of the directory to where you want to copy the file (e.g. cp filename directory-name ).
I would recommend using find
's -exec
option:
find . -ctime 15 -exec cp {} ../otherfolder \;
As always, consult the manpage for best results.
I usually use this one:
find . -ctime -15 -exec cp {} ../otherfolder/ \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With