在shell脚本中使用sed将行添加到文件中

问题描述 投票:1回答:1

我有一个包含109行的文件。

我在下面显示的行上执行两项操作。

# Delete line 74
sed -i '74d' Test.txt

# Add the entry to line 109
  sed -i "109iThis is the string" Test.txt

[我看到第74行从我的Test.txt中删除,但是由于某些原因,现在我的Test.txt只有108行,我看不到This is the string被添加到第109行。

我不确定是什么错误。你能帮我吗?

bash shell sed ksh
1个回答
0
投票

我建议使用:

sed -i "108iThis is the string" Test.txt
© www.soinside.com 2019 - 2024. All rights reserved.