I want to change the command \pause into %\pause in all my tex files. So I used the following Linux command:

for f in *.tex; do sed -i 's/\pause/%\pause/g' $f; done

but the problem is that the machine don't take into account the character \, so it only changes pause into %pause.

  • 3
    also the for loop is not needed, sed -i 's/\\pause/%\\pause/g' *.tex
    – Sundeep
    Mar 20 '17 at 14:08

You should escape \ with \\:

for f in ./*.tex; do sed -i -e 's/\\pause/%&/g' "$f"; done

Not the answer you're looking for? Browse other questions tagged or ask your own question.