0

I have to read out a CSV file using bash. But my loop quits after 1 iteration.

Code:

function readCSVFile () {
input="bitbucket-repositories.csv";
OLDIFS=$IFS
IFS=","
while read repo tool folder;
do
  cd websites || exit
  cloneRepo $repo
  checkRepo
  cd ../ || exit 0
  checkTool  -> calls another script (../script.bash) -> no ssh
  countCSVLines
done < $input
IFS=$OLDIFS

}

1 Answers1

2

Which of the custom commands read from stdin? One of them is consuming the rest of the input file.

Try using a different file descriptor for the while read loop:

while read -r -u3 repo tool folder; do ... done 3< "$input"
glenn jackman
  • 238,783
  • 38
  • 220
  • 352