@samshaw:
Perhaps you should open your own thread?
For a start try this:
Code:
HOSTS=( $(sed -n 's/^<hostAddress>\([^<]*\).*/\1/p' xfile) )
It will write the results of the
sed command into an array HOSTS.
Code:
echo ${HOSTS[1]} etc.
Will give you the values.
Sed is best learned by example. There are many pages with
sed one liners.
This one here does the following:
-n only print if asked to print a line
's/ substitute
^<host every line starting with host
\([^<]*\) every character except a "<" and save what you have found in "\1"
.* the rest of the line
/\1/ substitute by what we have just save in \1
p' print this line.
The command does two tasks at a time: a) it finds all lines starting with
host..., b) it extracts the value between the tags.
HTH Chris