GNU sed is our friend ... particularly its "-z" (alias "--null-data", alias "--zero-terminated") options.
> Gentlemen, just like the SQL language has a "LIMIT" operator, so also > does find need a -limit (and xargs a --limit) option. > > You might ask can't one just use e.g., > $ find|sed 3q > $ some_command|sed 3q|xargs ... > > and e.g., > $ find -print0 | perl -0nwe 'print; exit if $. == 3;' | xargs -0 ... > if needing to use nulls. If you're using GNU sed (which almost all users of GNU find will be), find -print0 | sed -z 3q | xargs -0 ... will do the trick. > Well yes one can, but > 1. at least give the null example on the man pages. Yes, this seems like a good idea to me. > 2. wouldn't it be much more efficient if the commands stopped output > themselves? Like > $ find -limit 3 -print0 | xargs -0 ... > or > $ any_command | xargs --limit 3 I don't think piping through sed is a significant run-time cost. Cheers -- Chris