Can someone point me what I may be missing here? How can put a file (with 100/1000 or lines in an array and whether it's possible. The lines will have spaces/special characters etc.
To mimic what I need is, here's an example. At command line, I can do this to create an array and it works.
[userMe@fastServer goga]$ aaa=("1 my name is koba" "2 you name is shenzi")
[userMe@fastServer goga]$ echo ${aaa[0]}
1 my name is koba
[userMe@fastServer goga]$ echo ${aaa[1]}
2 your name is shenzi
Now, What I want is: If I put those 2 lines in a file /tmp/ks.txt i.e.
[userMe@fastServer goga]$ cat /tmp/ks.txt
1 my name is koba
2 you name is shenzi
Then my questions are:
What command can I run to populate the array? I tried this but it didn't work, it's NOT taking the full first line in [0] and full 2nd line in [1] index.
aaa=($(cat /tmp/ks.txt | sed "s/^/\"/;s/$/\"/")); echo ${aaa[0]} and ${arr[1]}
How BASH array will work / their limit, when the file has 100000/more of lines in it.
I want to use Arrays (instead of using files) while doing grep command to find bunch of words in these lines. Thought using arrays will be faster than file operations. Please advise otherwise.