find files and copy them to a certain folder in bash (draft)

find . -name “*” | grep -i scomm | xargs ls -ltr | grep “Aug 13 10” | awk ‘{print $9}’

to use in the cp command (get the column number 9 which contains the file’s full path

cp `find . -name “*” | grep -i scomm | xargs ls -ltr | grep “Aug 13 10” | awk ‘{print $9}’` /sfs/aamr/scomm/sbprd02

If the search_string contains any special characters (e.g. dot, slash, double quotations …etc, then preceed it by a ‘\’

Advertisements

About SoCRaT

Research Support and Infrastructure Engineer, OSS & Linux Geek
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s