在 bash 脚本文件中,我设置了一个变量,如下所示:
current_path=`pwd`
sed -i "1s/.*/working_path='$current_path';/" file1.sh
我想运行这个脚本来替换file1.shinto的第一行working_path='$current_path';,但是在命令中current_path有/and是在替换模式中预定义的。我试过这个:sed/sed
current_path1="${current_path/\//\\\/}"
上面这行,我想把/in 变量替换current_path成\/,然后把 in 输入current_path1到sed命令中,也报错。
请给我一些建议好吗?谢谢。