Awk is a tool for text processing on Linux. It has a powerful field interception function. Today we will introduce how to use awk to process text data. Please see the detailed introduction below.
1. awk can display the content in the file, as shown in the figure below, awk displays the content in passwd, and is set to only display the first 5 pieces of information
2, awk separates the contents of passwd with colons, and takes out the 1st, 3rd and 6th digits of data
3. awk separates the contents in passwd with colons, takes out the 1st, 3rd, and 6th bits of data, and uses the tab key as separator
4. awk uses colon as the separator to display how many fields there are in a line
5. awk can also display the last field of each line
6. The awk command can also output the line number in front of each line
7, The awk command can indicate which row of data is displayed, as shown in the figure below, awk displays the fifth row of data in the passwd file
The above is the detailed content of Learn how to use awk command to process text data in Linux system. For more information, please follow other related articles on the PHP Chinese website!