Warum liefert "head -3" dieselben Ergebnisse wie "head -n 3"?

262
dhblah

Ich bin daran interessiert, warum headfunktioniert, da es mit vorgegebenen Parametern arbeitet, dh head -3die gleiche Ausgabe erzeugt wie head -n 3?

0

1 Antwort auf die Frage

4
slhck

From the Coreutils info pages for head (accessible through info coreutils 'head invocation'):

For compatibility head also supports an obsolete option syntax -COUNTOPTIONS, which is recognized only if it is specified first. COUNT is a decimal number optionally followed by a size letter (b, k, m) as in -c, or l to mean count by lines, or other option letters (cqv). Scripts intended for standard hosts should use -c COUNT or -n COUNT instead.

This is why the syntax is equivalent. man head doesn't tell you this, by the way.