从文件中删除带有字符的行(Remove lines with the character from the file)

编程入门 行业动态 更新时间:2024-10-28 02:20:44
从文件中删除带有字符的行(Remove lines with the character from the file)

我这样说了

'< Jan 20 Sep> This is the sample out put This is Sample > '< Jan 21 Sep> This is the sample out put This is Known Errors >

所以我需要从文件中删除所有>特殊字符。 只需要删除存在一个特殊字符>的行。 我想在下面说出来

'< Jan 20 Sep> This is the sample out put This is Sample '< Jan 21 Sep> This is the sample out put This is Known Errors

I have out put like this

'< Jan 20 Sep> This is the sample out put This is Sample > '< Jan 21 Sep> This is the sample out put This is Known Errors >

So i need to remove all > special character from the file. Only the line where one special character > is present needs to be removed. I would like to have below out put

'< Jan 20 Sep> This is the sample out put This is Sample '< Jan 21 Sep> This is the sample out put This is Known Errors

最满意答案

你可以使用sed

sed '/^>$/d' myfile

如果输出对你有好处,你可以使用-i标志来覆盖你的文件:

sed -i '/^>$/d' myfile

You can use sed

sed '/^>$/d' myfile

If the output if good for you, you can use the -i flag to override your file:

sed -i '/^>$/d' myfile

更多推荐

本文发布于:2023-08-04 22:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1424645.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符   文件   Remove   file   character

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!