I have a scenario that I have to put lines of a file .txt inside an array, example of file content;
type of host
|
| first host
| |
| | second host
| | |
| | | same ip address
| | | |
HOST_A_B=192.168.0.1
I have to put this on array in bash
#echo $Array[0]
HOST_A=192.168.0.1
#echo $Array[1]
HOST_B=192.168.0.1
and sometimes the lines don't have a second HOST like
HOST_A_B=192.168.0.1
HOST_C=192.168.0.2
HOST_DEF_G=192.168.0.3
and the echo command output should looks like,
#echo $Array[1]
HOST_A=192.168.0.1
#echo $Array[2]
HOST_B=192.168.0.1
#echo $Array[3]
HOST_C=192.168.0.2
#echo $Array[4]
HOST_DEF=192.168.0.3
#echo $Array[5]
HOST_G=192.168.0.3
Any idea?
> Array pos
the actual, literal output format you want? or are they some kind of abstract description of what you want? If the latter, then please add a sample of the actual output format. Also add a small but representative sample of your actual input file.