Maybe I'm asking this question wrong, but I can't seem to find the answer to this anywhere. What I'm trying to do is read the lines from a text file passed from the script call (./script.sh textile.txt) and read it into variable. My code is:
function read_hosts{
hosts = $(cat "$1")
}
read_hosts $@
the script call is:
./nexthelper.sh hosts.txt
And, hosts.txt contains the following:
localhost
www.google.com
When I run the code, it throws a syntax error on the hosts =
line. Any help would be greatly appreciated!