Issue
I have text file named file
that contains the following:
Australia AU 10
New Zealand NZ 1
...
If I use the following command to extract the country names from the first column:
awk '{print $1}' file
I get the following:
Australia
New
...
Only the first word of each country name is output.
How can I get the entire country name?
Solution
Try this:
$ awk '{print substr($0,1,15)}' file
Australia
New Zealand
Answered By - Raymond Hettinger Answer Checked By - Mary Flores (WPSolving Volunteer)