Question

I would like to del a line that contain the occurence in the first or second column (separator \t). For exemple :

line 1  uni:1 uni:2 blabla blabla

line 2  uni:3 EBI:1 blbla blabla

I Want to delete the line2. The "blabla" text can contain the occurence (EBI) but I don't want to select by the rest of the text, just with the two first column.

I try : awk -F "\t" '{print $1 $2}' file1 |grep -v EBI > file2 but this will stock just the first and second column and not the entire line.

I try this too : awk -F "\t" '{print $1 $2}'file1 |grep -n EBI and sed "numberOfLined" file1 >file2

But I have a lot of occurences so I don't want to write all numbers of lines by hand.

Était-ce utile?

La solution

You can use if statement and regex matching via ~:

awk -F '\t' '{if (! (($1 ~ ".*EBI.*") || ($2 ~ ".*EBI.*"))) {print $0} }'

And thanks to comments, it could looks even better:

awk '!($1~/EBI/ || $2~/EBI/)'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top