web | Java

用shell脚本怎么替换字符串(现场写)

千锋教育

vi /home/test/rep.sh #!/bin/bash ori_str=$1 rep_str=$2 grep_word=$3 file_dir=$4 sed -i "s/${ori_str}/${rep_str}/g" `grep "$grep_word" -rl $4` 


#数据源未目录或者文件即可测试: [root@hadoop01 test]# chmod a+x /home/test/rep.sh [root@hadoop01 test]# ./rep.sh abc 123 abc /home/test/