|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
search information in multiple files and save in new files
hi everyone,
im stuck in here with shell can you help me?? i have a directory with alot files (genbank files ... all ended in .gbk ) more than 1000 for sure ... and i want to read each one of them and search for some information and if i found the right one i save in new file with new name. i already get try for loops and no sucess well for search the information i get it right : awk 'BEGIN{RS="LOCUS"}/Equinodermata/{print "LOCUS"$0}' i only cant read each file and save in news! please help me i will give you a candy ![]() |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
awk 'BEGIN{RS="LOCUS"}/Equinodermata/{print "LOCUS"$0}' *.gbk >> new_file |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
sorry dont work out
and its for all files .gbk that i found Equinodermata inside save in different file not all together but its ok ... thanks for your help ![]() |
|
#4
|
||||
|
||||
|
Should this new file be in the same directory as the old one?
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
well this is not really important ... but yes could be in same directory
|
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Try: Code:
for file in *.gbk; do
awk 'BEGIN{RS="LOCUS"}/Equinodermata/{print "LOCUS"$0}' $file > new_$file
done |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
Code:
awk 'BEGIN{RS="LOCUS"}/Equinodermata/{print "LOCUS"$0 > FILENAME"_found"}' *gbkyour search patterns if found in a file say something.gbk, will be written into a new unique file something.gbk_found |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search & Replace: Multiple Strings / Multiple Files | spacegoose | Shell Programming and Scripting | 2 | 10-16-2012 08:17 PM |
| reading information from a table and apply a command on multiple files | @man | Shell Programming and Scripting | 5 | 10-02-2012 11:35 AM |
| extracting information from multiple files | houkto | Shell Programming and Scripting | 4 | 11-15-2011 02:51 PM |
| Search multiple patterns in multiple files | vsachan | Shell Programming and Scripting | 10 | 01-26-2011 04:48 PM |
| Merging information from multiple files to a single file | crunchie | Shell Programming and Scripting | 4 | 11-11-2010 05:19 AM |
|
|