help-bash
[Top][All Lists]
Advanced

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

Re: How to read \000?


From: Jeffrey Walton
Subject: Re: How to read \000?
Date: Wed, 15 May 2024 18:01:04 -0400

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 guess the problem is, what do
you want to do afterwards.


> On Wed, May 15, 2024 at 2:30 PM alex xmb sw ratchev <fxmbsw7@gmail.com>
> wrote:
> >
> > mapfile -d '' m < <( printf %s\\0 ab cd ) ; printf %s\\0 "${m[@]}"
> >
> > On Wed, May 15, 2024, 21:22 Peng Yu <pengyu.ut@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> $ echo -ne '\000a' | { read -N 1 x; declare -p x ; }
> >> declare -- x="a"
> >>
> >> read just skip \000 and read the next char "a". What if I want to read
> >> the underlying character, in this case, it is \000, then x should be
> >> just an empty string.
> >>
> >> Can this be achieved somehow in bash?
>


reply via email to

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