使用sed插入一行到一个空文件中

PonyCheng2019 2014-03-24 11:20:04
使用touch创建一个空文件,如何使用sed向这个文件中插入新行呢,我发现只要文件是空的,sed好像不管用了啊。
请大家指导指导,谢谢!
...全文
495 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Liteboy 2014-03-25
  • 打赏
  • 举报
回复
echo " " > file
ljc007 2014-03-25
  • 打赏
  • 举报
回复
可以考虑不用touch,改成别的命令:
echo "" >a.txt
ljc007 2014-03-25
  • 打赏
  • 举报
回复
Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed’s ability to filter text in a pipeline which particularly distin- guishes it from other types of editors. 它需要有输入
ljc007 2014-03-25
  • 打赏
  • 举报
回复
如果没有其它问题,请点击左上角“结帖”按钮
PonyCheng2019 2014-03-25
  • 打赏
  • 举报
回复
引用 2 楼 ljc007 的回复:
可以考虑不用touch,改成别的命令:
echo "" >a.txt
偶然发现的,当时用echo替代了,thank you...

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧