andreia
October 23, 2012, 12:59pm
1
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
awk 'BEGIN{RS="LOCUS"}/Equinodermata/{print "LOCUS"$0}' *.gbk >> new_file
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
Should this new file be in the same directory as the old one?
well this is not really important ... but yes could be in same directory
Try:
for file in *.gbk; do
awk 'BEGIN{RS="LOCUS"}/Equinodermata/{print "LOCUS"$0}' $file > new_$file
done
msabhi
October 23, 2012, 5:11pm
7
awk 'BEGIN{RS="LOCUS"}/Equinodermata/{print "LOCUS"$0 > FILENAME"_found"}' *gbk
your search patterns if found in a file say something.gbk, will be written into a new unique file something.gbk_found