bug-bash
[Top][All Lists]
Advanced

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

Re: EOF does not work in echo


From: Chris F.A. Johnson
Subject: Re: EOF does not work in echo
Date: Thu, 25 May 2006 20:04:11 -0400
User-agent: slrn/0.9.8.1 (Linux)

On 2006-05-25, Cai Qian wrote:
> Hi,
>
> echo -e "hello \004world" | cat
>
> will print out
>
> hello world

    As it should.

> echo -e "hello \004world" | cat > /dev/null
>
> will print out nothing

    Of course: you sent it all to /dev/null.

> It suggests that "cat" has not seen EOF (004) generated by echo.

    Try piping it to od or hexdump:

$ echo -e "hello \000world" | hexdump -C
00000000  68 65 6c 6c 6f 20 00 77  6f 72 6c 64 0a           |hello .world.|
0000000d

    Do you expect cat to stop printing after \004? It won't; it will
    print all characters. If it didn't, it would be of no use for
    concatenating binary files.

-- 
   Chris F.A. Johnson                      <http://cfaj.freeshell.org>
   ===================================================================
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)


reply via email to

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