Manipulating text with awk, gawk and sed
The awk, gawk and sed commands on Linux are extremely versatile tools for manipulating text, rearranging columns, generating reports and modifying file content.Using awk and gawk To select portions of command output using gawk, you can try commands like those below. The first displays the first field in the output of the date command. The second displays the last field. Since NF represents the number of fields in the command output, $NF represents the value of the last field.$ date | awk '{print $1}' Sat $ date | awk '{print $NF}' 2023 Note that on Linux systems today, awk is usually a symbolic link to gawk, so you can type either command and get the same result. Here's what you'll probably see when you do a long listing of the awk executable:To read this article in full, please click here