in a folder, I have 2 files. Valuation.csv and another file myScript.sh
My CSV file has 10 lines and 5 columns. I have tried to read it multiple times but it never worked. This is what I have tried as code inside my myScript.sh:
First try:
#!/bin/bash
while read -r line do
field1=$(echo $line | awk -F'|' '{printf "%s", $1}' | tr -d '"')
field2=$(echo $line | awk -F'|' '{printf "%s", $2}' | tr -d '"')
echo $field1 $field2 done < $Valuation.csv
Result: /myScript.sh: line 10: .csv: No such file or directory
Second try:
cat Valuation.csv|while read line do
read -d, col1 col2 < <(echo $line)
echo "I got:$col1|$col2" done
Result: nothing
I am running the file like this:
./myScript.sh
thank you
.csvand post the data as text, not a picture of the spreadheet. Bash can't read a picture of the spreadsheet.Valuationis empty/undefined. Aside from this, I don't think it is a good idea to process CSV in this way, as it works only with fairly simple CSV files. For instance, theawkpart does not work if one of the fields contain a (quoted)|as value.