Article Title: replacing File Content in batches in linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. Readily available materials on the Internet
Format: sed-I "s/search field/replace field/g" 'grep search field-rl Path'
Linux sed replaces strings in multiple files in batches
Sed-I "s/oldstring/newstring/g" 'grep oldstring-rl yourdir'
For example, replace www.admin99.net with admin99.net in all files under/home.
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. attach 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' // In fact, multiple file names are generated by ls.