Need to append file name to all rows in in .csv file

Hi ,

Can some one help in appending the file name to all the rows in .csv files the current work is like this.
This is adding a new line for file name,
I need to append file name to all lines in .csv

for i in `ls $filename*.csv`
do
echo "$i" > ./tmpfile
cat "$i" >> ./tmpfile
mv ./tmpfile "$i"
echo $i
sqlldr userid=$login control=.ctl data=$i log=/tmp/$i.log bad=/tmp/$i.bad
mv $i $destdir
done
exit 0

You can try someyhing like that (assume ';' as field separator in the .csv files) :

for i in `ls $filename*.csv`
do
   awk -v OFS=';' '{print $0,FILENAME}' "$i" > ./tmpfile
   mv ./tmpfile "$i"
   echo $i
   sqlldr userid=$login control=.ctl data=$i log=/tmp/$i.log bad=/tmp/$i.bad
   mv $i $destdir
done
exit 0

Jean-Pierre.

Sorry it doen't work as and loads the entire data in the first field

Please give us an example of input data file, the result you need (file to be loaded with sqlldr) and the contents of your control file.

Jean-Pierre.