Read the first line of a file using bash
Solution 1:
read -r FIRSTLINE < filename
Same result as the other answers but faster because it doesn't spawn any process, as "read" is a built-in bash command.
Solution 2:
head -1
simply
Solution 3:
FIRSTLINE=`head -n 1 filename`
Stores the line in a variable for later use (note the inverted apostrophes).
Solution 4:
head -n 1
should do the trick