Reputation: 1
I'm trying to automate git cloning for a class and I'm having trouble with formatting the string in bash.
#!/bin/sh
students=()
while IFS=, read -r lastname firstname; do
#students+="$lastname$firstname"
student=$lastname$firstname
echo $student
echo $lastname
git clone "...$student/unit02.git" $student
done < studentNames.csv | tr -d '" '
The echo will produce the correct format, the names without quotation marks. When cloning, however, both uses of the $student variable returns back to unformatted.
Upvotes: 0
Views: 45
Reputation: 3154
Perhaps try:
while IFS=, read -r lastname firstname; do
<logic>
done < <( tr -d '" ' < studentNames.csv )
When you write < studentNames.csv | tr -d '" '
you aren't passing a filtered file into the while loop, you're passing an unfiltered file into the while loop and then filtering all the output. The echo statements print the right values because they're being filtered on the spot, but the values in the variables aren't correct.
Upvotes: 1