我已经为此绞尽脑汁三天了。
假设我有一个名为“test.sh”的文件,还有另一个名为“update.sh”的文件,其中包含一些用于更改或更新“test.sh”脚本的“sed”命令。
“update.sh”脚本中的所有其他“sed”命令一切正常,它更新“test.sh”文件也很好,除了以下内容......
我有一行无法让“sed”更新。
所以我在“test.sh”脚本中有以下行...
LC_ALL=C PYTHONHASHSEED=0 chroot . dpkg -i --path-include="/usr/share/doc/*" "${deb_list[@]}"
我需要将其更新为...
LC_ALL=C PYTHONHASHSEED=0 chroot . dpkg -i --force-overwrite --path-include="/usr/share/doc/*" "${deb_list[@]}"
我当前的“sed”命令看起来像这样......
sed -i 's|LC_ALL=C PYTHONHASHSEED=0 chroot . dpkg -i --path-include="/usr/share/doc/*" "${deb_list[@]}"|LC_ALL=C PYTHONHASHSEED=0 chroot . dpkg -i --force-overwrite --path-include="/usr/share/doc/*" "${deb_list[@]}"|' test.sh
注意:我使用的是“|”作为我的分隔符。
而且这不起作用。我尝试了各种变体,转义字符等,但没有任何效果。
我将不胜感激任何有关此问题的帮助/线索。
您需要什么:
sed -i 's/dpkg -i/& --force-overwrite/' file
LC_ALL=C PYTHONHASHSEED=0 chroot . dpkg -i --force-overwrite --path-include="/usr/share/doc/*" "${deb_list[@]}"