除去起始以小写字符的行 [英] Remove all lines starting with a lower case character
本文介绍了除去起始以小写字符的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从一个文件,如果他们以小写字符或标点符号开始删除所有行?
How to remove all lines from a file if they begin with a lower case character or punctuation?
A bamboo forest is located towards the ruins.
a banana .
aban Bajramovi was a Serbian-Romani musician.
Abancay is a city in southern-central Peru.
! a ban is the strictest punishment.
我想我的输出仅仅是:
I would like my output to simply be:
A bamboo forest is located towards the ruins.
Abancay is a city in southern-central Peru.
我试图用sed
I'm trying sed
sed 's/^[A-Z]/d' input
但没有得到预期的效果,任何提示?
But not getting desired results, any tips?
推荐答案
试试这个:
sed '/^[a-z[:punct:]]/d' file
,也可以使用字符类都是由<一的建议href=\"http://stackoverflow.com/questions/22491064/remove-all-lines-starting-with-a-lower-case-character#comment34217124_22491101\">@glennjackman在注释:
sed '/^[[:lower:][:punct:]]/d' file
$ cat file
A bamboo forest is located towards the ruins.
a banana .
aban Bajramovi was a Serbian-Romani musician.
Abancay is a city in southern-central Peru.
! a ban is the strictest punishment.
$ sed '/^[a-z[:punct:]]/d' file
A bamboo forest is located towards the ruins.
Abancay is a city in southern-central Peru.
$ sed '/^[[:lower:][:punct:]]/d' file
A bamboo forest is located towards the ruins.
Abancay is a city in southern-central Peru.
这篇关于除去起始以小写字符的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文