Im trying to understand sed command and loops. I need to take part of the text (20 lines) and append it to the csv with the file name. here is my code
for i in ~/mspl/*.doc
do
catdoc "$i" > auto.txt
sed -e '1,20!d' auto.txt > auto1.txt
sed -e '1s/^/"$i" ;/' auto1.txt > auto2.txt
sed -e '20s/$/~/' auto2.txt > auto3.txt
cat auto3.txt >> lines.csv
done
the problem is that my second "i" argument doesn't convert to the file name in csv.
in the line
sed -e '1s/^/"$i" ;/' auto1.txt > auto2.txt
Please tell what is my mistake here?