我正在寻找一种在 sed 语句中添加多个空格的干净方法。在语句中有文字空格有效:
sed -i 's/this is a test/\n and so is this/' test_file.txt
但我希望有一种更精确的方法来使用正则表达式来实现这一点。谢谢!
我正在寻找一种在 sed 语句中添加多个空格的干净方法。在语句中有文字空格有效:
sed -i 's/this is a test/\n and so is this/' test_file.txt
但我希望有一种更精确的方法来使用正则表达式来实现这一点。谢谢!
使用
bash
orzsh
,您可以在变量中获得任意数量的空格:使用
zsh
,您还可以执行以下操作: