使用sed在源文件上直接替换某一行的内容,只替换第一次找到的那行

sed -i 's/^mysqld_pid_file_path=.*$/mysqld_pid_file_path=/data/mysql/run/mysqld.pid/' /etc/init.d/mysqld
sed -i "s/^lockdir=.*$/lockdir='/data/mysql/lock/subsys'/" /etc/init.d/mysqld
原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/14652205.html