I have in a directory some *.csv files. I want to insert inside each file, its name.
The following code do it, but I also need to remove, delete the pattern .csv
for file in *.csv; do echo "$file,"$"$(cat -- "$file")" > "$file"; done
for example if the name is London.csv and inside I have 10, 20, now I get
London.csv, 10, 20
I need to reduce it to,
London, 10, 20
With your help, I get it with this update
for file in *.csv; do echo ${file%.csv},"$"$(cat -- "$file")" > "$file"; done