I have the following tsv-file (extract):
File 1:
NC_002163.1 RefSeq source 1 1641481 . + . organism=Campylobacter jejuni subsp. jejuni NCTC 11168;mol_type=genomic DNA;strain=NCTC 11168;sub_species=jejuni;db_xref=taxon:192222
NC_002163.1 RefSeq misc_feature 19386 19445 . - . inference=protein motif:TMHMM:2.0;note=3 probable transmembrane helices predicted for Cj0012c Further possible text
NC_002163.1 RefSeq misc_feature 19482 19550 . - . inference=protein motif:TMHMM:2.0;note=3 probable transmembrane helices predicted for Cj0014c Sometimes there is more text
NC_002163.1 RefSeq misc_feature 22853 22921 . - . inference=protein motif:TMHMM:2.0;note=5 probable transmembrane helices predicted for Cj0017c
...
As you can see, the last column contains some identifiers (Cj0014c, Cj0017c, etc
). Some of these IDs are saved in another file
File 2:
Cj0012c
Cj0027
CjNC9
Cjp01
SRP_RNA_Cjs03
CjNC11
CjNC1
Cj0113
Cjp03
Cj0197c
Cj0251c
How can I use awk (or any bash-script-tool) to eliminate those lines from File 1, that contain as substring in the last column, any ID that is found in File 2? For example, the second line of File 1 would be deleted, since Cj0012c
is found in File 2 and is part of the string in the last column of the line in File 1.
I've been struggling already many hours, so thanks for any help (and, if possible, an explanation of the code!)
grep -v -f file1 file2
? (I don't post as answer, I didn't quiet get what you meant by substring , should line containing anywhereCjp0
be removed asCjp01
andCjp03
are in file1 ?)File 1
delimited? how should we know thatCjxxx
is a substring in the last column, rather than a separate field value?