Trying to use awk
to find a keyword and return the matches in the row, but also $1 and $2
, which are the unique id's, but they only appear once. Thank you :).
file
name 31 Index Chromosomal Position Gene Inheritance
122 2106725 TSC2 AD
124 2115481 TSC2 AD
121 2105400 TSC2 AD
82 135782221 TSC1 AD
81 135782026 TSC1 AD
126 2138218 TSC2 AD
123 2113107 TSC2 AD
125 2126142 TSC2 AD
name2 12 Index Chromosomal Position Gene Inheritance
1 43396568 SLC2A1 AD, AR
name3 20 Index Chromosomal Position Gene Inheritance
188 2135240 TSC1 AD
179 2103379 TSC1 AD
191 2137899 TSC2 AD
181 2110617 TSC2 AD
190 2137857 TSC2 AD
189 2137806 TSC2 AD
186 2133798 TSC2 AD
187 2135074 TSC2 AD
180 2105400 TSC2 AD
183 2122822 TSC2 AD
192 2138218 TSC2 AD
185 2125937 TSC2 AD
184 2125788 TSC2 AD
193 2138269 TSC2 AD
182 2112981 TSC2 AD
Desired output
name 31 Index Chromosomal Position Gene Inheritance
82 135782221 TSC1 AD
81 135782026 TSC1 AD
name3 20 Index Chromosomal Position Gene Inheritance
188 2135240 TSC1 AD
179 2103379 TSC1 AD
191 2137899 TSC1 AD
awk
awk '/TSC1/{ print $1,$2,$0 }' file.txt > output.txt