Wednesday, December 14, 2022

Linux - Awk

The following is a Linux dictionary word of the day:

awk used for pattern matching, text processing and reporting.

The name Awk is derived from the last name initials of its designers: Alfred V. Aho, Peter J. Weinberger, and Brian W. Kernighan. The first version of Awk was written in 1977.

The syntax of awk is as such:
awk options 'selection_criteria { action }' input-file > output-file

Example: Using awk to show how to extract column 5 (the file size) from the output of ls -l.

ls –l | awk ‘{print $5}’

Note: notice that the output of the awk ‘{print $5}’ is the fifth column of the ls -l command
as shown for reference.

print is the command to print out output.
print $5 means print the fifth column.


No comments:

Post a Comment