Replacing a row of records in a property file with a shell script
Assume a subordinate file demo.properties
User.name=test
user.password=123456
...............................
Requirements: First, you need to replace the value values of User.Name and User.password with the user name and password that you actually need through the shell script.
will be implemented in the following ways:
Sed-i "s#^user.name=.* #user. Name= User name #g" path/demo.properties
Sed-i "s#^user.password=.* #user. password= password #g" path/demo.properties
The contents of the demo properties file are then replaced.
Put the above sed two lines into the. Sh script, when the execution of the error, refer to the following link
Http://stackoverflow.com/questions/7648328/getting-sed-error
Add a "" after-I, and the complete script will read as follows:
#!/bin/shsed"" "s#^user.name=.* #user. Name=admin#g" sed "" " s#^user.password=.* #user. Password=000000#g " Demo.properties
Demo.properties is to modify the properties file, because the file and script in the same directory, so the name can be directly written here, if not in the same directory, you need to write the full directory
Reference Address: http://blog.csdn.net/wangmuming/article/details/19605281
Modify properties file with Shell script under Mac