The head
command is almost certainly outputting the requested number of bytes, however what those bytes are is affecting how they are displayed in your terminal.
Specifically, your gunzipped file almost certainly has DOS-style CRLF line endings, with a CR at byte 30 and LF at byte 31. When you do head -c29
, the head output excludes both line ending bytes, and you see something like
yourname@computer:~$ head -c29 file.warc
WARC/1.0
WARC-Type: responseyourname@computer:~$
with your shell prompt following directly after the 29th byte. When you do head -c31
, you capture both the CR and the LF, and the output looks like
yourname@computer:~$ head -c31 file.warc
WARC/1.0
WARC-Type: response
yourname@computer:~$
However when you do head -c30
, the output contains the terminating CR but not its following LF - the cursor is sent back to position 0, but is left on the same line of the terminal, where it is then overwritten by your shell prompt:
yourname@computer:~$ head -c31 file.warc
WARC/1.0
yourname@computer:~$
If the line is longer than your prompt, you will see characters from the file peeking out beyond the end. If your PS1
prompt was empty, then you would have seen the full expected output.