Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 442 Bytes

awk.md

File metadata and controls

20 lines (17 loc) · 442 Bytes

Note

OFS (Output Field Separator) is ignored when using { print } instead of { print $1,$2,$3... }.

How to trim leading and trailing spaces on each line

awk '{$1=$1};1' input.txt

How to show lines that contain a substring

# The following shows:
# apple
# pineapple
echo "apple\norange\npineapple" | awk '/apple/ { print $0 }'

How to show the last column

awk -F, '{print $NF}' input.txt