perl - If a sentence starts with a specific word, how to change a word in that sentence if it does exist? -


so, searching lines in .txt file , if starts word such "this", how swap targeted word in sentence if exist? open doing bash, perl or awk.

perl -pi -e "s/^this\b/that/" myfile 

or, if want change different word within line,

perl -pi -e "s/\btargeted\b/swap/ if /^this\b/" myfile 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -