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
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.
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
Summary: Thank you James and William. It worked under bash (cygwin). But I tried to apply it on another example and it didn't seem working: f1 file: cell_name cell_id ------------- ALW102B 426-01-101-1022 ...
Summary: What UNIX command can I use to get this output: Smith 3 Jones 1 Arnold 2 from a file with these contents Smith Jones Smith Arnold Smith Arnold Any help or suggestions would be greatly appreciated... B...
Summary: You can build a variable that sort can use; here is an example of sorting myfile with the first field: #!/bin/ksh str="1,1 my.file" sort -k $(echo "$str") You can build variable str from a file's cont...