Greetings,
I am having a hard time with this one. I am trying to use a for loop to update a specific line in a handful of session files. The line in the session files I am looking to append is:
Code:
HostName=
The 'hostlist' file has a list of hosts. Each line in the 'hostlist' file is unique and matches exactly to the output of 'ls'.
Here's what I have thus far:
Code:
HOST=$(cat hostlist)
for i in $(ls); do sed 's/HostName\=/HostName\=$HOST/g' $i > $i.temp; done
It doesn't matter whether I use no quotes, single quotes or double quotes, it either will add the literal $HOST to the files or nothing at all.
Since the line I am wishing to replace is the same in every file, I have also tried line replacement in sed with similar results:
Code:
#!/bin/bash
HOST=$(cat hostlist)
FILE=$(ls)
sed '2 r $HOST' $FILE > $FILE.temp
Any thoughts?
Thank you in advance!
Brenden