In Linux, replace the strings-sed and grep in a certain type of files in batches.
Source: Internet
Author: User
Linux batch replaces the strings-sed and grep in a certain type of files with the following problems: use the macro variable % {_ relea... linux batch replaces the strings-sed and grep in a certain type of files with the following problems: you need to replace the version number in the Release row in the spec configuration file of about 100 source codes with the macro variable % {_ release. If you want to manually modify it, you need to modify it more than 100 times, but using the sed and grep commands is simple: [plain] sed-I "s/Release: 1/Release: % {_ release}/g "'grep Release: 1-rl -- include = "*. spec ". /'The above Command is to be verified. I have written it for the time being. please confirm it tomorrow and modify it. A simple method to replace strings in multiple files in batches in Linux. You can use the sed command to replace strings in multiple files in batches. You can use the sed command to replace strings in multiple files in batches. Sed-I "s/original string/new string/g" 'grep original string-rl Directory 'for example: I want to replace mahuinan with huinanma and execute the command: sed-I "s/mahuinan/huinanma/g" 'grep mahuinan-rl/www 'is currently the simplest string replacement command in linux! The specific format is as follows: sed-I "s/oldString/newString/g" 'grep oldString-rl/path' instance code: sed-I "s/size/Sun/month/g" 'grep size-rl/usr/aa 'SED-I "s/size/Sun/month/g "' grep size-rl. /'
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.