It is possible to create a sed command with multiple replace strings:
sed -e 's/erors/errors/g' -e 's/last/final/g' my_file.txt > Tmp
To run it just fire up this command:
find . -name "*.v" | xargs -n1 | xargs -i= ./tiRm.unx = where tiRm.unx is the name of the bash file.
Sometimes only one file is involved. In this case vim can be used to do the conditional replace operation. :g/0b/s/\([01]\) \(([01]\)/\1\2/g This will remove space between binary [01], if it finds the binary symbol 0b Another example is to replace some annoying ^M, which sometimes appear, when importing files from DOS to unix. :g/ctrlVctrlM/s///g
vim replace on blocks:
You can use line numbers or vim marks to define a replace zone area. 12,23g/polarity_cnt/s//polarity_cnt_dbg/g 'a,'b g/polarity_cnt/s//polarity_cnt_dbg/g
where the block is defined by the vim commands ma and mb.
To run a script on a block from vim go to : perl script on run on block form within vim
Or do it from the command line using perl to do the job of string replace: perl -i -pe 's/00/99/;' Italian_top_100.txt
The following script may be helpful, should you need to replace a string in many files:
Note the the script is extremely simple. But its operation is a bit complex:
find . -name "*.c" | xargs -n1 | xargs -i= replace_with_sed_script.unx =
A similar issue is discussed at: search into multiple files and generate a report The solution in this page uses a for f (similar to perl's foreach statement) and therefore results in a simpler script.
Contact me now at:
...
I would be happy to offer my services. Call ASAP !