Im confused with how the following cut works in the bash script.
Sample of file.csv
:
#10.10.10.10;28;9.10.10.10: up;Something ;More random spaces
My script:
#!/bin/bash
csv_file="file.csv"
locations=( $( cut -d';' -f5 $csv_file ) )
for ((i=0; i < ${#locations[@]}; i++))
do
echo "${locations[$i]}"
done
The result of the script is:
More
random
spaces
When I just copy and paste the cut in my CLI without any echos or variables the cut works as I´d expect and prints:
More random spaces
I am sure it´s some bracket or quote problem, but I just can't figure it out.