GNU/Linux >> Linux Esercitazione >  >> Linux

Come eseguire un equivalente di `head -z` quando non ho l'opzione `-z` disponibile?

Ho bisogno di head -z per uno script (fuori tema, ma la motivazione può essere trovata in questa domanda), ma nel mio CoreOS 835.13.0 ottengo head: invalid option -- 'z' .

head --help uscita:

Usage: head [OPTION]... [FILE]...
Print the first 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.
With no FILE, or when FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
  -c, --bytes=[-]K         print the first K bytes of each file;
                             with the leading '-', print all but the last
                             K bytes of each file
  -n, --lines=[-]K         print the first K lines instead of the first 10;
                             with the leading '-', print all but the last
                             K lines of each file
  -q, --quiet, --silent    never print headers giving file names
  -v, --verbose            always print headers giving file names
      --help     display this help and exit
      --version  output version information and exit

K may have a multiplier suffix:
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report head translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'head invocation'

La parte divertente è che l'ultima riga mi dice di eseguire info coreutils 'head invocation' ma ottengo info: command not found .

Risposta accettata:

Scambia NUL e NL prima e dopo la testa:

Linux
  1. Come aggiungere una nuova riga alla fine di un file?

  2. Come evitare il messaggio di avviso "sono lo stesso file" quando si utilizza cp in Linux?

  3. Quando leggo un file con "meno" o "più", come posso ottenere il contenuto a colori?

  4. Come posso risolvere l'errore che non può eseguire il file binario?

  5. Come trovare il file manager predefinito?

Come utilizzare il comando head di Linux

Come eseguire un file .sh all'inizio della sessione?

Come eseguire il file python in linux

Come posso fare in modo che tcpdump scriva su file e emetta in output standard i dati appropriati?

Come posso analizzare l'output del comando find quando i nomi dei file contengono spazi?

Come catturare tutti i dischi che non hanno un file system