I am trying to find .csv file in directory and assign its name to a variable in a shell script.
I have written following code.
x="$(find extracted_data/*.csv)"
echo "$x"
IFS = $'\n'
for i in "${x[@]}"; do
echo "${i}"
done
However, after running this code I get following output:
extracted_data/another_file.csv
extracted_data/sample.csv
sheet.sh: 4: IFS: not found
sheet.sh: 5: Bad substitution
What is wrong done in code as it is giving those two errors?
I have followed following two links for my code loop through file names returned by find and for array