I want to list my vars in a script so they look like
while read IN
var1
var2
var3
var4
do
echo $IN
done
Then in the same script have them read and processed.
the closest I can get is as follows but this is obviously wrong.
NOTE I want a list not all the entries on one line, that would be too easy.
while read IN; hello; you; other; test; ok; do echo $IN; done
Perhaps I should use a EOF tag?
hope this makes sense.
Thanks
---------- Post updated at 04:42 PM ---------- Previous update was at 04:19 PM ----------
By George I did it on my own.
LIST=`cat << EOF
ls
echo
udevinfo
fdisk
xdisk
dmidecode
lsusb
EOF`
echo $LIST
read
for i in $LIST
do
if which $i &> /dev/null
then
echo "There it is $i"
else
echo "$i It's not there"
fi
done
I think this is the right way any other suggestions are welcome though, I'd like to make it look cleaner.
i suggest put all the commands to a parameter file and read through it instead of writing it in a script. if in case you need to add more you can do so in the parameter file instead.
Thanks for your suggestions, I always find it interesting to see other peoples variations. (there are many ways to skin a cat as they say.)
I tried to use the type command but unfortunately it was not installed on all the servers the script was to run on, so I used a simple if test to see if the executable file existed instead.