题解 | #打印空行的行号#
打印空行的行号
http://www.nowcoder.com/practice/030fc368e42e44b8b1f8985a8d6ad255
- grep匹配空行,awk去掉冒号
grep -n '^$' nowcoder.txt | awk -F: '{print $1}'
- awk正则匹配空行,然后呢输出行数
awk '/^$/{print NR}' nowcoder.txt
- sed正则匹配空行,=输出行数
sed -n '/^$/=' nowcoder.txt