2016-08-01 31 views
-1

刪除角色我已經放出來這樣
從文件

'< 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 

回答

3

您可以使用SED

sed '/^>$/d' myfile 

如果輸出,如果對你有好處,你可以使用-i標誌覆蓋文件:

sed -i '/^>$/d' myfile 
0
grep -fvx '>' <myfile >myfile_with_offending_lines_removed 
+0

這並沒有提供問題的答案。要批評或要求作者澄清,請在其帖子下方留言。 - [來自評論](/評論/低質量帖/ 13196081) –

+0

我認爲它確實提供了一個答案。如果OP運行這個命令,他以請求的格式獲得輸出。我錯過了什麼? – user1934428