shell - Extracting lines from a file that match a list of IDs -
hopefully i'm going make sense here...
i have huge file - each line represents data different individual. want grep (or extract) out information (lines) individuals - don't want keep greping out individuals individually appending @ end curious whether there loop can set proving text file ids (ie id001, id002... id100) or variable unique each individual. i'm new programming i'm not sure should googling/looking answer - possible in shell?
apologies might simple question.
thanks!
edit 1: i'm adding little more info here: format might different file genetics file , has following format:
fam001 id001 a t t tc t a…… g fam001 id002 a t t c c g…… t c fam004 id003 a t g t g a…… g . . fam100 id100 g c t c g t g…… t g
is possible set loop, say, similar to/includes this:
for f in $( cat ~/famid.txt )
with famid.txt as:
fam001 fam050 fam087
to able run analysis on individuals famid id running program on families in list provided?
hope makes sense.
this need:
grep -wff famid.txt data.txt
where:
-f famid.txt
tells grep read patterns file-f
tells grep patterns plain strings can pick appropriate matching engine-w
tells grep match patterns form whole word (so if accidentally "fam" in pattern file, don't match every line of data file)
Comments
Post a Comment