head -num는 iv가 아닌 head -n num와 동일합니다. id = “b8f09f62ea”>

(여기서 num는 임의의 숫자)

예 :

$ echo -e "a\nb\nc\nd"|head -1 a $ echo -e "a\nb\nc\nd"|head -n 1 a $ echo -e "a\nb\nc\nd"|head -n -1 a b c 

head -1는 어디에도 문서화되지 않은 것 같습니다.

$ 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=[-]NUM print the first NUM bytes of each file; with the leading "-", print all but the last NUM bytes of each file -n, --lines=[-]NUM print the first NUM lines instead of the first 10; with the leading "-", print all but the last NUM lines of each file -q, --quiet, --silent never print headers giving file names -v, --verbose always print headers giving file names -z, --zero-terminated line delimiter is NUL, not newline --help display this help and exit --version output version information and exit NUM 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: <https://www.gnu.org/software/coreutils/> Full documentation at: <https://www.gnu.org/software/coreutils/head> or available locally via: info "(coreutils) head invocation" 

head의 매뉴얼 페이지 (Fedora 28) :

HEAD(1) User Commands HEAD(1) NAME head - output the first part of files SYNOPSIS head [OPTION]... [FILE]... DESCRIPTION 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=[-]NUM print the first NUM bytes of each file; with the leading "-", print all but the last NUM bytes of each file -n, --lines=[-]NUM print the first NUM lines instead of the first 10; with the leading "-", print all but the last NUM lines of each file -q, --quiet, --silent never print headers giving file names -v, --verbose always print headers giving file names -z, --zero-terminated line delimiter is NUL, not newline --help display this help and exit --version output version information and exit NUM 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. AUTHOR Written by David MacKenzie and Jim Meyering. REPORTING BUGS GNU coreutils online help: <https://www.gnu.org/software/coreutils/> Report head translation bugs to <https://translationproject.org/team/> COPYRIGHT Copyright © 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO tail(1) Full documentation at: <https://www.gnu.org/software/coreutils/head> or available locally via: info "(coreutils) head invocation" GNU coreutils 8.29 December 2017 HEAD(1) 

답변

정보 페이지 및 온라인 설명서 GNU head에는 다음 부분이 포함됩니다.

호환성 head 또한 오래된 옵션 구문 -[NUM][bkm][cqv]를 지원합니다.이 구문은 먼저 지정된 경우에만 인식됩니다.

아이디어 head -1head -n 1와 동일하다는 것은 대시가 mi가 아니라는 것입니다. nus 기호이지만 명령 줄 옵션의 표식입니다. 이것이 일반적인 관례입니다. 대시로 시작하는 것은 처리 방법을 제어하는 옵션이고 명령 줄의 다른 항목은 처리 할 파일 이름 또는 기타 실제 대상입니다.이 경우 단일 문자 옵션이 아닙니다. 그러나 -n의 약어이지만 기본적으로 파일 이름이 아닌 옵션입니다. head +1 또는 , +1 또는 1는 파일 이름으로 간주됩니다.

이중 대시 -- 또는 --something도 그 자체로 고유 한 의미를 갖습니다 (--). 옵션 처리를 중지하고 다른 것이 뒤 따르면 GNU 스타일의 긴 옵션을 표시합니다. 따라서 head -n -1에 대해 head --1를 사용하면 안됩니다. 관습과 일치하십시오.

추측한다면, 긍정적 인 i에 대해 -n i의 기이 한 단축키가 존재한다고 가정합니다. 음수 i의 경우 전자 사례가 더 자주 유용하고 구현하기 쉽기 때문입니다. (게다가 표준 head 는 행의 양수 값에 대해서만 정의됩니다.)

설명

답글 남기기

이메일 주소를 발행하지 않을 것입니다. 필수 항목은 *(으)로 표시합니다