Monday, July 22, 2013

replace all in file from console


The command is:
sed -i 's/oldString/newString/g' fileToBeReplaced.txt

For MAC the behaviour is more restrictive, and wants to specify an backup file this way:
sed -i.bak 's/oldString/newString/g' fileToBeReplaced.txt

In this case, a backup file ("fileToBeReplaced.txt.bak") will be created.

No comments:

Post a Comment