#!/bin/bash #generate some data and put ina file # see manpage to see what -e option does filename=foo.txt echo -e "cow\ngoat\npig\nhorse" > $filename #read stuff from a file with a for loop for line in $(cat $filename) do echo "The line is $line" done #read stuff from a file with a while loop while read line do echo "The line is $line" done < $filename