Skip to main content
Protected against filenames with spaces and cases where the 1st field is a subset of the file name
Source Link
terdon
  • 252.9k
  • 69
  • 481
  • 720

Before told about perl speed try to speed up your own script

for f in *file*.csv; do sed -i "/^$f,/! s/^/$f,/" $f"$f" done 

Before told about perl speed try to speed up your own script

for f in *file*.csv; do sed -i "/^$f/! s/^/$f,/" $f done 

Before told about perl speed try to speed up your own script

for f in *file*.csv; do sed -i "/^$f,/! s/^/$f,/" "$f" done 
Source Link
Costas
  • 15.1k
  • 24
  • 38

Before told about perl speed try to speed up your own script

for f in *file*.csv; do sed -i "/^$f/! s/^/$f,/" $f done