[root@mail ~]# cat aa.txt
hahahaha
aaaaaaa
aaaaaaa
bbbbbbbbbbbbb
vvvvvvvv
ddddddddd
vvvvvvvv
aaaaaaa
bbbbbbbbbbbbb
ddddddddddd
$
#
345
345
a5^
[root@mail ~]# sed -n '/[a-zA-Z0-9@#$%^&*]/!=' aa.txt
4
[root@mail ~]# grep -n ^$ aa.txt (感谢soulmate)
4:
[root@mail ~]# awk '/^$/{print NR}' aa.txt (感谢继续飞翔)
4
[root@mail ~]# sed -n '/^$/=' aa.txt (感谢继续飞翔)
4
转载于:https://blog.51cto.com/297020555/579640