In Linux system, after copying many files, only a few of them need to be modified. At this time, the SED command can be used to replace and modify at one time.



File_ All old char in name file is replaced by new char, and the corresponding replacement syntax is as follows:



# sed -i "s/od-char/new-char/g" file_ name



Note: the above marked in red need to be changed, other formats do not need to be changed





Example 1: when creating the MySQL master - slave environment, copy a 3306 file and replace it with 3307 in the configuration file. You can use the following method:



Other parameters can be changed from 3306 to 3306 my.cnf All 3306 in the file can be replaced with 3307, and the following command can be used for one-time modification:

$ sed -i "s/3306/3307/g" /data/mysqldata/3307/ my.cnf





Example 2: when creating Oracle 12C plugged database, you need to replace different file system paths:



$ sed -i "s/orapdb01/orapdb03/g" /home/oracle/orapdb03.xml

© 2024 www.topnovel.cc