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?
line=$(head -1 file)
Will work fine. (As previous answer). But
line=$(read -r FIRSTLINE < filename)
will be marginally faster as read is a built-in bash command.
read