May 2013
Beginner to intermediate
384 pages
7h 40m
English
We may have a file having a number of columns, and only a few will actually be useful. For example, in a list of students in an order of their scores, we want to get, for instance, the fourth highest scorer. In this recipe, we will see how to do this.
The most widely-used method is to use awk for doing this task. It can be also done using cut.
$ awk '{ print $5 }' filename
For example, to print the permission and filename of each file in the current directory, use the following set of commands:
$ ls -l | awk '{ print $1 " : " $8 }' -rw-r--r-- : delimited_data.txt ...
Read now
Unlock full access