我正在使用Unix sed
命令进行一些操作。我正在尝试替换和附加命令,在一个文件中。但难点是,我必须创建一个中间文件,然后执行mv
将其重命名为原始文件。如何替换而不在sed中创建中间文件?
有没有办法在同一个文件中一次性完成它?
[[email protected] practice]# sed '1i\
> Today is Sunday
> ' file1 > file1
[[email protected] practice]# cat file1
[[email protected] practice]#
该文件被删除!
[[email protected] practice]# sed 's/director/painter/' file1 > file1
[[email protected] practice]# cat file1
该文件被删除!
有人投了我的问题吗?但为什么? – kingsmasher1