[awk] Print a specific input line

Created on November 30, 2026

Use NR to select a record by its number. With the default line-based input, NR == 2 selects the second line.

printf 'apple\norange\nbanana\n' | awk 'NR == 2'
orange
awk Shell command