头不返回 n 行

头不返回 n 行

当我运行该命令时,head -n 445 /etc/snort/snort.conf | nl我期望返回第 1-445 行。但是,仅返回第 371 行:

[snip]
370 preprocessor dcerpc2_server: default, policy WinXP, \
371     detect [smb [139, 445], tcp 35, udp 135, rpc-over-http-server 593], \

怎么了?

答案1

默认情况下,该nl实用程序不对空行进行编号(并且输入文件中有空行)。

答案2

这是您应该运行的命令:

nl -ba ./etc/snort/snort.conf | grep output

然后找到“输出”所在的实际行(对我来说,是 529)。获得行号后,输入以下命令:

nl -ba ./etc/snort/snort.conf | tail -n+523 | head -n

您的“-n+523”将替换为“-n+<您的行号减 6>”。如果您不想在输出中对行进行编号,请省略 snort.conf 目录前面的“nl -ba ”

相关内容