Issue
There is several lines in a file that looks like:
A B C H
A B C D
and, I want to print all lines that contain this RE:
/A\tB/
But, if the line contain and H
in the fourth field, do not print, the output would be:
A B C D
It could be written in one line in sed, awk or grep?
The only thing that I know is:
awk '/^A\tB/'
Solution
With awk one-liner:
awk -F'\t' '$1=="A" && $2=="B" && $4!="H"' file
-F'\t'
- tab char\t
is treated as field separator
The output:
A B C D
Answered By - RomanPerekhrest Answer Checked By - Dawn Plyler (WPSolving Volunteer)