mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-08 21:34:25 +00:00
1.3 KiB
1.3 KiB
awk
TL;DR
# Print only the 3rd column.
awk '{print $3}' sales.txt
cat sales.txt | awk '{print $3}'
# Print the 2nd and 3rd columns, separated with a comma.
awk '{print $2 ", " $3}' sales.txt
cat sales.txt | awk '{print $2 ", " $3}'
# Print the sum of the 2nd and 3rd columns.
awk '{print $2 + $3}' sales.txt
# Print only lines with a length of more than 20 characters.
awk 'length($0) > 20' sales.txt
# Print only lines where the value of the second column is greater than 100.
awk '$2 > 100' sales.txt
# Print only the last column.
echo 'maps.google.com' | awk -F. '{print $NF}'
awk -F '/' '{print $NF}' <<< 'test/with/slashes'