This blog contains Linux / Unix Tips and Tricks, collected during my work as a Unix System Administrator.
They are here for my own reference, but they might help you as well !
len | 15 December, 2008 07:42
Here's a perl oneliner that does text search & replace over multiple files. Make sure you create a backup before using it !
This example will replace all occurences of "oldserver" to "newserver" in the *.conf files:
$ perl -pi -e 's/oldserver/newserver/g' *.conf
If you combine it with find you can even do search and replace recursively over directories.
This example will replace all occurences "10.0.0.1" to "192.168.1.1" in all files under /data:
$ find /data -type f | xargs perl -pi -e 's/10.0.0.1/192.168.1.1/g'
Len Kranendonk
Unix System Specialist.
Broad experience in web development and open source technologies.
| « | December 2008 | » | ||||
|---|---|---|---|---|---|---|
| Mo | Tu | We | Th | Fr | Sa | Su |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 | ||||