Noor
Noor

Reputation: 19

shell for loop to read files inside a directory

I have comma separated files in directory I want to read all files using for loop, tried following code

echo on

cd \tmp\Documents

`for /r %%i in (*csv) do "hello World" %%i`

getting 2 errors

1. Syntax Error near unexpected token '%%i'
2. $'/r' command not found

please help me to sort it out

Upvotes: 0

Views: 726

Answers (1)

Ahmed farag mostafa
Ahmed farag mostafa

Reputation: 2934

you can try this - just replace the DIR_TO_READ_FROM with the directory where you are storing the CSV

for file in "${DIR_TO_READ_FROM}"/*.csv
do
  echo "$file"
done 

Upvotes: 1

Related Questions