Reputation: 11
what is wrong with following code?
TEXT=$(<"$(pwd)/data.csv")
IFS=','
cut -d, -f1,2 $TEXT | while read street city ; do
echo "$street $city"
done
If I am providing the file name directly then it is working
IFS=','
cut -d, -f1,2 data.csv | while read street city ; do
echo "$street $city"
done
Upvotes: 0
Views: 534
Reputation: 5770
How can i store file name as a variable in shell script
#!/bin/bash
FILEPATH="$(pwd)/something"
echo $FILEPATH
Upvotes: 1
Reputation: 610
Why not simply execute this code:
while read street city ; do
echo "$street $city"
done < data.csv
Upvotes: 0