I have a file named input_file which contains some lines. I need to remove certain characters in the line and store them in an array. So to remove the characters, I use the sed command and storing in a variable as below.
all_values=$(sed 's/^[^.]*\. //' < input_file) echo "$all_values"
It is working perfectly fine but I need all_values
to be an array so that all_values[0]
will contain the first line and all_values[1]
the second line and so on.
Since I have a file, I do not know the total array elements before hand. How can I construct an array for my case?
EDIT:
My input file is like below.
This is first element This is second element Though spaces, I should be one element