fee a list into a script?

May 25, 2010 at 03:26:54
Specs: redhat linux
Hi, I have a basic script that runs a command;

host hostname1 > list.txt
host hostname2 >>list.txt

over and over again on a manual list where I
have entered hostname1 through hostname100

I also have a list of all the hostnames that I
want to run the command host on. is there a
simple way to replace hostname with a
variable and then step through each line in turn
appending to the text file each time.

I think I should be looking at while command
but I can't seem to get the syntax right.

Thanks in advance, Rob.

See More: fee a list into a script?

Report •

May 25, 2010 at 07:54:43

rm -f list.txt
while read host
   host $host >> list.txt
done < hostlist.txt

Report •
Related Solutions

Ask Question