
head -z
스크립트가 필요합니다 (주제에서 벗어났지만 동기를 찾을 수 있음).이 질문에는), 하지만 내 CoreOS 835.13.0에서는 head: invalid option -- 'z'
.
전체 head --help
출력:
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'
흥미롭게도 마지막 줄에는 달리라고 나와 있지만, info coreutils 'head invocation'
나는 그 말을 이해합니다 info: command not found
.
답변1
head 전후에 NUL과 NL을 바꿉니다.
<file tr '\0\n' '\n\0' | head | tr '\n\0' '\0\n'
최신 버전의 GNU를 사용하세요 sed
:
sed -z 10q
GNU 사용 awk
:
gawk -v RS='\0' -v ORS='\0' '{print}; NR == 10 {exit}'