1. Ready-made information on the Internet
Format: Sed-i "s/lookup field/replace field/g" ' grep lookup field-rl path '
linux sed Bulk replaces strings in multiple files : (This command is very powerful)
sed-i "s/oldstring/newstring/g" ' grep oldstring-rl yourdir '
explain:
- I. represents inplace edit, in-place modify file
-R means recursive, searching subdirectories
-L = line number, output matching file name
For example: Replace the www.admin99.net in all files under/home to Admin99.net
Sed-i "s/www.admin99.net/admin99.net/g" ' grep www.admin99.net-rl/home '
Exp:sed-i "s/shabi/$/g" ' grep shabi-rl./'
2, self-added additional
2.1 Replace the text "garden" in file 1.txt with "Mirgarden"
# sed-i "s/garden/mirgarden/g" 1.txt//sed-i very simple
2.2 Replace "garden" in all files in the current directory with "Mirgarden"
# # Sed-i "s/garden/mirgarden/g" ' ls '//is actually the LS out of multiple filenames
Transferred from: http://www.cnblogs.com/end/archive/2012/05/24/2517131.html
Bulk Replace file contents under Linux