Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Redirection (<>)



> >From zsh.info:
> `<>WORD'
>      Open file WORD for reading and writing as standard input.  If the
                                                 ^^^^^^^^^^^^^^
>      file does not exist then it is created.
> 
> and here's what happens when I try to use it.
> 
> ~/tmp% cat > f         
> a b d f
> c d c
> c c d
> e c d
> ~/tmp% sed "s/c/f/g" <> f
> a b d f
> f d f
> f f d
> e f d
> ~/tmp% cat f
> a b d f
> c d c
> c c d
> e c d
> ~/tmp% 
> 
> And my question is; Why does the output from sed go to stdout?
> 
> What does <> really mean?

It means that the file is opened rw as stdin (instead of read-only, as
normal). sed sends its output to stdout.

If you had a program that tried to write to stdin it would normally fail
(presumably), but wouldn't if you used <>.
(Note: I haven't tried this).

Owen




Messages sorted by: Reverse Date, Date, Thread, Author