Skip to main content

Timeline for grep and sed in specific

Current License: CC BY-SA 3.0

7 events
when toggle format what by license comment
Aug 19, 2016 at 15:21 comment added Stephen Harris 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' {} \;
Aug 19, 2016 at 15:18 comment added infoclogged Looks like it is working. But, can you please tell me if I can do it recursively in all files and directories?
Aug 19, 2016 at 15:07 comment added Stephen Harris 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`
Aug 19, 2016 at 15:07 comment added infoclogged Should the x replaced by *.tex, since I only want to modify the tex files?
Aug 19, 2016 at 15:04 comment added infoclogged Thanks, is there something called a dry-run or interactive mode while running the above?
Aug 19, 2016 at 15:04 comment added Stéphane Chazelas 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.
Aug 19, 2016 at 14:56 history answered Stephen Harris CC BY-SA 3.0