简体   繁体   中英

Remove lines with the character from the file

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

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
grep -fvx '>' <myfile >myfile_with_offending_lines_removed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM