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 ‘\’

Unknown's avatar

About Ahmed Tawfik

Cybersecurity Professional, Systems Engineer, OSS & Linux Geek
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a comment