题解 | #打印空行的行号#
打印空行的行号
https://www.nowcoder.com/practice/030fc368e42e44b8b1f8985a8d6ad255
1. grep -n '^$' nowcoder.txt |cut -d ':' -f 1 2. grep -n '^$' nowcoder.txt | awk -F: '{print $1}' 3. grep -n '^$' nowcoder.txt | sed 's/\:/\ /g' 4. awk 'NF==0{print NR}' nowcoder.txt。NF :当前记录(行)中的字段数(即分隔符分割后的列数) 5. awk '/^$/ {print NR}' ; NR :当前记录行号 ;