0

The following is the data in my file and i want to load it using bash script

eth0/0,up,up,text
eth0/1,up,up,text2
eth0/2,down,down,text3

i want to load these in array and compare each lines

if [ ${myArray[2]} == "up" ]; then
echo ${myArray[3}
elif ${myArray[2]} == "down"; then
echo ${myArray[3]}
else
echo "error"
fi

I want to compare the arrays and provide the last array as the output

Output

eth0/0 up text
Alter Ego
  • 71
  • 1
  • 7
  • Does this answer your question? [How do I split a string on a delimiter in Bash?](https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash) – Clément Baconnier Nov 16 '19 at 18:13
  • 1
    This might help: `while IFS="," read -r -a array; do declare -p array; done < file.csv` – Cyrus Nov 16 '19 at 18:19

0 Answers0