0 shell command-line command-line-arguments
我如何更改特定行的此文本
假设我想更改第 50 行,并且我想更改“user”之后的 8 个字母: 就像下面我加粗的例子
第 50 行“用户”:“ 9077c266 -8944-11eb-a9d1-fa163e4be1a2”
使用s命令 insed进行搜索和替换。
sed -i 'Ns/9077c266/replacement-line/' file.txt
Run Code Online (Sandbox Code Playgroud)
whereN应该替换为您的目标行号。
要将更改的文本保存在不同的文件中,请删除 -i 选项:
sed 'Ns/9077c266/replacement-line/' file.txt > new_file.txt
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
49 次 |
| 最近记录: |