Using AWK commandto print out only the first fields that has 4 letters
hi I got a text file and need to use awk command to print out various information from it.
I've managed to print out all the variations less one. Anyone can help guide me how the command goes. The expected result is as follows.
Example file containing:
mark 10 20 30
mike 10 20 30
Johnny 10 20 30
I want to use awk command and print out only the first field if it contains only 4 letters. Meaning the commands output should be:
mark
mike
the closest I got to was with the following command:
Code:
awk '$1 ~ /[a-z][a-z][a-z][a-z]$/{print $1}' myfile.txt
But it prints out all the fields in that line. Thanks for helping.