Techiee Techiee - 1 month ago 6
Linux Question

What does awk '/a/ {print $4 "\t" $3} abc.txt mean?

I am learning awk and I was confused with the following command:

awk '/a/ {print $4 "\t" $3}' abc.txt


What does
/a/
mean? I was reading the Sed & awk, 2nd Edition by Dale Dougherty. Probably, I didn't reach that part of
/a/
text processing part. Hence asked this question.

Answer

for every line in the abc.txt file it test if it has a "a" character. If it does prints the fourth word in that line, then a tab character and then the third word.

Comments