i have 1 tab delimited file column 1 being id , column 2 being information. i've second file list of ids need removed first file. when use grep, either copy of first file no changes or blank file using -v -f -f "file2.txt" flags/arguments. question is: how use file2.txt compare ids file1 eliminate rows file1 output file3.
awk 'begin{rs=">"}nr>1{sub("\n","\t"); gsub("\n",""); print rs$0}' $1 > fasta.tab grep -f -f $2 fasta.tab -v >rmoutput.tab tr '\t' \n' <rmoutput.tab >rmoutput.fas echo runtime complete
line 1: create tab-delim file input 1 line 2: check input 2 matches , remove tab-delim file line 3: recreate format of input 1 (for clarity)
edit: sample i/o
input 1 (tab-delim--after line 1):
id1 info1 id2 info2 id3 info3 id4 info4 id5 info5
input 2 (ids deleted):
id2 id4 id5
desired output (from line 2)
id1 info1 id3 info3
awk 'nr==fnr{a[$0];next} !($1 in a)' input2 input1
Comments
Post a Comment