This is a Korn shell question. I want to put the results of a grep into an array. So, I did the following:
set -A newarray `grep XYXYXY testfile.txt`
But this puts each word into an array index instead putting each line into an array index. For ex. if the grep matches the following lines:
My name is XYXYXY
Your name is XYXYXY
then the array output is:
My
name
is
XYXYXY
Your
name
is
XYXYXY
I want the array to take the entire lines such that
newarray[0] = My name is XYXYXY
newarray[1] = Your name is XYXYXY
How can this be done?? Do I have to loop through each line in the file to put lines into the array??
Thanks
Cheap Computer Part Supply Buying Tips
VOIP Phone Service Guide
set -A newarray `grep XYXYXY testfile.txt`
But this puts each word into an array index instead putting each line into an array index. For ex. if the grep matches the following lines:
My name is XYXYXY
Your name is XYXYXY
then the array output is:
My
name
is
XYXYXY
Your
name
is
XYXYXY
I want the array to take the entire lines such that
newarray[0] = My name is XYXYXY
newarray[1] = Your name is XYXYXY
How can this be done?? Do I have to loop through each line in the file to put lines into the array??
Thanks
Cheap Computer Part Supply Buying Tips
VOIP Phone Service Guide