I have a shell script that looks like the following:
#!/bin/bash
for file in $1/*.html; do
echo "Working on $file ..."
# delete headers in html files.
sed -n '1,9d' $file
# delete the last 4 lines of the file.
sed -n -e :a -e '1,4!{P;N;D;};N;ba'
# ant runs regex task on all apt files
ant -Dtarget.file=$file
# all .html are changed to .md
mv $file `echo $file | sed 's/\(.*\.\)html/\1md/'` ;
done
but the script hangs on the first sed command and I have to force exit. I'm wondering if there's anything wrong about the way I've set this up?
If I remove the first two sed commands, I can run the other parts of the script, including that final one with a sed command in it.
mvmakes me cringe due to the useless and expensive fork to yet anothersed. If you just want to replace an extension in a filename stored in a variable, usemv $file ${file%.html}.md.