Add a new snippet
Displaying first line from a file in UNIX
Displaying first line from a file
Using head command, we can display the first line.
head -1 filename.txt
For printing first "n" lines from the file, we can use
head -n filename.txt
Another way: (using sed)
sed ‘2,$ d’ file.txt
How it works ?
"d" tells sed to remove all lines from second line to the end of file ($).
So, you can see only the first line.
Tags for Displaying first line from a file in UNIX
Displaying lines of Code in Unix
Contribute to Forget Code, help others.