Using sed
you can do something like,
for f in *.csv
do
sed -i 's/$/ '"$f"'/' "$f"
done
Testing
Inside one of the directories, I created couple of csv
files.
cat csv1.csv
this
is
first
csv
file
##Second CSV file
cat csv2.csv
this
is
second
csv
file
Now, I executed the above command that I had mentioned. After the execution of the command, the files look like below.
cat csv1.csv
this csv1.csv
is csv1.csv
first csv1.csv
csv csv1.csv
file csv1.csv
##Second CSV file
cat csv2.csv
this csv2.csv
is csv2.csv
second csv2.csv
csv csv2.csv
file csv2.csv
If you want semicolons you can just add it in the sed
command before appending the file name. Change the sed
command like below.
sed -i 's/$/ '";$f"'/' "$f"
References
http://www.unix.com/unix-for-dummies-questions-and-answers/150545-merge-files-add-file-name-end-each-line.html