让我们创建一个示例文本file.txt:
add character at the beginning of each line
使用sed命令添加每行开头的字符。
例如,要在每行的前面添加#,我们可以使用以下语法使用sed命令:
$ sed 's/^/#/' file.txt #add #character #at the #beginning of #each line
在每行前面添加空格:
$ sed 's/^/ /' file.txt add character at the beginning of each line
将输出结果保存到文件:
$ sed 's/^/ /' file.txt > new-file.txt
$ cat new-file.txt add character at the beginning of each line
日期:2020-07-07 20:54:32 来源:oir作者:oir