I have to put in a bash variable the first line of a file. I guess it is with the grep command, but it is any way to restrict the number of lines?
head takes the first lines from a file, and the -n parameter can be used to specify how many lines should be extracted:
head
-n
line=$(head -n 1 filename)