|
Simple loop in Bash
Hi,
I want to do a simple loop where I have one column of text in a file and I want the loop to read each line of the file and do a simple command.
The text file will be something like this:
hostname1
hostname2
hostname3
hostname4
I am using Bash and have already come up with this to create the text file:
grep hostname /etc/hosts|awk '{print $2}'
how can I take the contents of that file and do a simple loop? for starters, let's just echo the contents of the file. I can add my command later. Not sure if i need a for loop or a while loop.
Any help will be appreciated.
|