Find and replace a word from a file

Sometimes, you might want to find and replace a bunch of word from a file and you do not actually needed a word editor such as vi, pico, nano or emacs to open and modify it.

From Linux, you could directly using perl to replace them.
perl -pi -e ’s/wordToFind/replaceWithThisWord/g’ *.fileExtension

For example, you have all word linux want to replace with mickgenie, you may use the command as below.

perl -pi -e ’s/linux/mickgenie/g’ bogo.txt

Published by

Mick Genie

Mick Genie is the founder of and working at ExaBytes Network Sdn Bhd and WPWebHost web host company. He is expertise in Windows and Linux environment especially web hosting related information, tips and trick as well as the IT Information.