natjohan's blog

Posted dim. 04 août 2013

Tip of the week 23

Search and replace a character string in multiple files with sed

`Sed`, Stream Editor is a Unix utility that parses and transforms text.

Here is a simple and useful example : replace the character string 'priority 300' by 'bandwidth priority percent 10' in all .txt files in our current directory

find . -type f -iname '*.txt' -exec sed -i 's/priority 300/bandwidth priority percent 10/' {} +
Category: ToTW
Tags: sed replace files recursive

Comments