Hi,
I have a file called "readfile" it contains below parameters
#cat readfile
word=/abc=225,/abc/cba=150 three=12 four=45 five=/xyz/yza
likewise multiple line.
From the above file, I have to read "word"
output should be like,
/abc
/abc/cba
these values need to be put in an array.
to understand your req clear please more lines from input file and also the reason why it needed in array? also let us know the shell you are working on?
Hi,
Thanks for quick reply,
requirement:
runtime a script has to read a file and get the values of "word"
here "word" may contains one or two fields separated by comma,
word=/abc=225,/abc/cba
as it has two fields, So I need to put it in an array, so that I can use each filed at a time.
RudiC
June 27, 2013, 3:36pm
4
Try
awk '{for (i=1; i<=NF; i++) if ($i ~ /word/) {split ($i, A, "[=,]"); print A[2] " " A[4]}}' file
/abc /abc/cba
and read man bash
(or whatever your shell be) on how to assign to an array.