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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -