Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

GREP for sorting

$
0
0
Hi ,

I have a file which has a large number of sequences of type:

gi_1
AASSKSKSKSSKSKSK....
series_121
DDKFKFKGKGKH
gi_3
FFFFLFFLFLFLF
series_1
DFFFFFF
pattern_3
GEEEEEEEEE
gi_2
HKKGGKGKGK
series_102
HHHHH
pattern_1
HHHHH

In order to list all the sequences under gi I do
grep "gi" filename>outputfile
it gives me list of all gi .

However I want to list all of the sequences as shown below.I want to basically know the order like gi_1 followed by series_1 and by gi_3

gi_1
series_121
gi_3
series_1
pattern_3
gi_2
series_102
pattern_1


Is it possible to get all this in a single file and that too in the order they appear in file?

Should i do a multiple grep command to get all these names in a single file to get the order.


Thanks
Sia

Viewing all articles
Browse latest Browse all 16232

Trending Articles