Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • But when using GNU sed -i, you may want to actually only modify the files that need to be modified, so using grep and sed may actually make sense. Commented Aug 19, 2016 at 15:04
  • Thanks, is there something called a dry-run or interactive mode while running the above? Commented Aug 19, 2016 at 15:04
  • Should the x replaced by *.tex, since I only want to modify the tex files? Commented Aug 19, 2016 at 15:07
  • When using sed in this way it doesn't change the file, so it is effectively dry-run mode. You would add the -i flag to do an "in-place" change and update the file. eg sed -i 's!......!g mytext.tex` Commented Aug 19, 2016 at 15:07
  • 1
    The sed command is designed to work on a single file at a time. You would need to wrap it (eg in a loop, or via xargs) to make it work on multiple files. How you do the loop does the recursion; eg something like find . -name '*.tex' -exec sed -i.bak 's!....!g' {} \; Commented Aug 19, 2016 at 15:21