help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to read \000?


From: Koichi Murase
Subject: Re: How to read \000?
Date: Thu, 16 May 2024 09:39:25 +0900

2024年5月16日(木) 9:28 Jeffrey Walton <noloader@gmail.com>:
> On Wed, May 15, 2024 at 6:20 PM Greg Wooledge <greg@wooledge.org> wrote:
> > On Wed, May 15, 2024 at 06:01:04PM -0400, Jeffrey Walton wrote:
> > > On Wed, May 15, 2024 at 3:48 PM Peng Yu <pengyu.ut@gmail.com> wrote:
> > > > No. I need to just read one character.
> > > `tail -c +1` will read just one character.
> > I think you have the wrong command.  Perhaps you meant "head -c 1"?
>
> [...]
>
> -n specifies lines, while -c specifies characters.

It's not the count of characters. It's the count of bytes regardless
of the character encoding.

> Since -c is only
> available with tail, you have to use tail -c +1

However, `tail -c +N' means to print the N-th byte *and all the
subsequent characters*. It cannot be used to read one character. In
other words, `tail -c +N' is used to skip the first (N-1) bytes. The
suggested `tail -c +1' skips 0 bytes, so it's equivalent to `cat'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]