0

I'm trying to store the first 5 lines from a file in the variable url. But I get an error

-n5: command not found

fn_all_urls stores the path to the file /home/urls.txt

My Line is:

url=head -n5 ${fn_all_urls} #get first 5 lines in file
echo "$url"

I'm using bash on Ubuntu 18.04 64 bit

muru
  • 72,889
Rick T
  • 357

1 Answers1

1

You are not performing a command substitution, which is how you assign the output of a command to a variable. The proper syntax to accomplish this is:

url=$(head -n5 "${fn_all_urls}")
jesse_b
  • 37,005