Hello All,
I have a bash script and in it at some point I call an Expect Script that does some stuff and saves its
output in a ".txt" file.
Example "/path/to/my/file/Expect_Output.txt" file: notice the 2nd line is empty in the file...
Data for Host-1 (192.168.1.110)
Checking the status...
Status is GOOD
Then later on in my Bash script, I run the following command to put all the contents of the file
into an array, line-by-line...
EXPECT_OUTPUT="/path/to/my/file/Expect_Output.txt"
outputArray=( $(cat "$EXPECT_OUTPUT") )
I thought the contents of the array should be this:
(0) = "Data for Host-1 (192.168.1.110)"
(1) = ""
(2) = "Checking the status..."
(3) = "Status is GOOD"
But when I loop through the array and echo out the data I get the following:
for ((x=0; x <= ${#outputArray[@]}; x++))
do
echo "${outputArray[$x]}"
done
_____OUTPUT_____
Data for Host-1 (192.168.1.110)
Checking the status...
Status is GOOD
Does anyone know why it wouldn't retain the empty line when saving into the array?
Any thoughts would be much appreciated...!
Thanks in Advance,
Matt