Variables
$1 $2/$(NF-1) $3/$NF
â¼ â¼ â¼
ââââââââ¬âââââââââââââââ¬ââââââââ
$0/NR ⶠâ ID â WEBSITE â URI â
ââââââââ¼âââââââââââââââ¼ââââââââ¤
$0/NR ⶠâ 1 â quickref.me â awk â
ââââââââ¼âââââââââââââââ¼ââââââââ¤
$0/NR ⶠâ 2 â google.com â 25 â
ââââââââ´âââââââââââââââ´ââââââââ
# First and last field
awk -F: '{print $1,$NF}' /etc/passwd
# With line number
awk -F: '{print NR, $0}' /etc/passwd
# Second last field
awk -F: '{print $(NF-1)}' /etc/passwd
# Custom string
awk -F: '{print $1 "=" $6}' /etc/passwd
See: Variables
Comments