PracticalWeb Ltd

Websites that work for you.

Insert Line to All Files When Missing

In this case to turn on comments in all posts for this blog

All files that don’t have comments at the start of a line get “comments: true” inserted on the 5th line

1
2
for f in * ; do grep -q "^comments" $f || sed -i '5 i\
comments: true' $f ; done

Maybe Octopress has a way to globally enable comments - but I didn’t find it and this was quick

Comments