Dav*_*ill 1 command-line text-processing
我有一个很大的管道分隔文件,我需要在其中找到某个字段为空的所有行的行号。
我可以用来cut -d \| -f 6 filename.txt只输出那一列。
我可以使用什么实用程序/工具/命令来查找上面的哪些输出行是空的?
# cut -d \| -f 6 test.txt | grep -v -E .\+ -n
grep
-v invert match
-E .\+ match any 1+ character
-n output line numbers
Run Code Online (Sandbox Code Playgroud)
您可以将cut和结合起来grep,如其他人所示,或者您可以使用通用文本过滤器awk。
awk -F'|' '$6 == "" {print NR}'
Run Code Online (Sandbox Code Playgroud)