How can I execute an equivalent of `head -z` when I don't have the `-z` option available?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I need head -z
for a script (off-topic, but the motivation can be found in this question), but in my CoreOS 835.13.0 I get head: invalid option -- 'z'
.
Full head --help
output:
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'
The funny part is that the last line tells me to run info coreutils 'head invocation'
but I get info: command not found
.
coreutils head coreos
add a comment |Â
up vote
3
down vote
favorite
I need head -z
for a script (off-topic, but the motivation can be found in this question), but in my CoreOS 835.13.0 I get head: invalid option -- 'z'
.
Full head --help
output:
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'
The funny part is that the last line tells me to run info coreutils 'head invocation'
but I get info: command not found
.
coreutils head coreos
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I need head -z
for a script (off-topic, but the motivation can be found in this question), but in my CoreOS 835.13.0 I get head: invalid option -- 'z'
.
Full head --help
output:
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'
The funny part is that the last line tells me to run info coreutils 'head invocation'
but I get info: command not found
.
coreutils head coreos
I need head -z
for a script (off-topic, but the motivation can be found in this question), but in my CoreOS 835.13.0 I get head: invalid option -- 'z'
.
Full head --help
output:
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'
The funny part is that the last line tells me to run info coreutils 'head invocation'
but I get info: command not found
.
coreutils head coreos
coreutils head coreos
asked Sep 5 at 15:57
Pedro A
1163
1163
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
Swap NULs and NLs before and after head:
<file tr 'n' 'n' | head | tr 'n' 'n'
With recent versions of GNU sed
:
sed -z 10q
With GNU awk
:
gawk -v RS='' -v ORS='' 'print; NR == 10 exit'
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
Swap NULs and NLs before and after head:
<file tr 'n' 'n' | head | tr 'n' 'n'
With recent versions of GNU sed
:
sed -z 10q
With GNU awk
:
gawk -v RS='' -v ORS='' 'print; NR == 10 exit'
add a comment |Â
up vote
4
down vote
Swap NULs and NLs before and after head:
<file tr 'n' 'n' | head | tr 'n' 'n'
With recent versions of GNU sed
:
sed -z 10q
With GNU awk
:
gawk -v RS='' -v ORS='' 'print; NR == 10 exit'
add a comment |Â
up vote
4
down vote
up vote
4
down vote
Swap NULs and NLs before and after head:
<file tr 'n' 'n' | head | tr 'n' 'n'
With recent versions of GNU sed
:
sed -z 10q
With GNU awk
:
gawk -v RS='' -v ORS='' 'print; NR == 10 exit'
Swap NULs and NLs before and after head:
<file tr 'n' 'n' | head | tr 'n' 'n'
With recent versions of GNU sed
:
sed -z 10q
With GNU awk
:
gawk -v RS='' -v ORS='' 'print; NR == 10 exit'
answered Sep 5 at 16:26
Stéphane Chazelas
286k53528866
286k53528866
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f467066%2fhow-can-i-execute-an-equivalent-of-head-z-when-i-dont-have-the-z-option-a%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password