Computing.Net > Forums > Unix > copy files with pattern from a file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

copy files with pattern from a file

Reply to Message Icon

Name: t4t
Date: May 18, 2004 at 22:12:13 Pacific
OS: Unix
CPU/Ram: 512
Comment:

Hi,

I'm a relatively new Unix users.

I would like to copy files from "May 13" only to a different directory but don't know how. I appreciate if you could help.

An additional simple question with vi editor, I would like to remove the first 54 character on every single line of a text file, insert head of every single lines with different string. Please advise the quickest way to do this.


Thanks & Regards
T.T.




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: May 19, 2004 at 15:16:08 Pacific
Reply:

T.T.

I'm assuming you want to copy files with a creation date of May 13. The 6th and 7th fields of the 'ls -l' command are the month and day:

#!/bin/ksh

ls -l |while read f1 f2 f3 f4 f5 f6 f7 f8 f9
do
if [[ $f6 == "May" && $f7 = 13 ]]
then
echo "$f6 $f7 $f9"
cp $f9 diffdir
if [[ $? > 0 ]]
then
error "copy error with $f9"
fi
fi
done


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: copy files with pattern from a file

Update Column from a Reference file www.computing.net/answers/unix/update-column-from-a-reference-file/5737.html

Grouping data from a file www.computing.net/answers/unix/grouping-data-from-a-file/6135.html

Sort keys provided from a file www.computing.net/answers/unix/sort-keys-provided-from-a-file/8020.html