Substitute String or line in a file
Hi all,
I have built a base configuration file (AWstats configuration file), I have to make a many customized configuration file from that file, and I need to write a script to do that. the case is I need to substitute a certain lines in the base config file for every custom new file. what command (or commands) should I user to search for the specified line, delete it , and put in my customized new line ? Thanks for help. |
Assuming the file you want to modify is abc.log
then ... #>cat abc.log |perl -e ' foreach (<>) { s/SubtituteWhat/SubstituteWith/ig; print; } ' > abc_modified.log |
Thanks , this works :) :)
Great idea with perl saneax. it substitute a particular sentence or matching string , it is useful and i will need it later but for now,, how can I remove the complete line that contains the "Search for what" string ? i need to remove the complete line by matching a small part of it , then i need to place another line instead of it. |
#>cat abc.log |perl -e ' foreach (<> ) { s/.+SubtituteWhat.+/SubstituteWith/i; print; } ' > abc_modified.log
regards |
thanks again.
|
All times are GMT -5. The time now is 08:01 PM. |