How do I print the first line of a file?

Nam Lê

Member
How do I print the first line of a file?
Answer
To store the line itself, use the
var=$(command)
syntax. In this case, line=$(awk ‘NR==1 {print; exit}’ file) . With the equivalent line=$(sed -n ‘1p’ file) .
 

Tìm kiếm

Back
Top