Unix:限制 DIFF 命令的输出行数

Unix: Limiting the amount of lines of output from DIFF command

这是一个相当低级的问题,但是如何将 diff 的输出限制为(例如)5 行。

我是 运行 bourne shell,我知道 diff -c 和 diff -c 5,但是 none 这些命令对我有用。还有其他方法吗?

你用的是哪个diff,在NetBSD上,我可以使用以下限制:

% diff ~/.zshrc* | grep '[<>]' | head -5
< setopt autocd interactivecomments
< CASE_SENSITIVE="true"
< DISABLE_LS_COLORS="true"
< #plugins=(git)
> plugins=(git)

希望对您有所帮助!