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
Post a Comment