Naresh Naresh - 4 months ago 8
Bash Question

Remove the 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

Answer

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
Comments