Monday, August 17, 2009

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 '\'

No comments: