[Top][All Lists]

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

Re: echo foo > a b does not error

From: Greg Wooledge
Subject: Re: echo foo > a b does not error
Date: Thu, 12 May 2011 08:31:40 -0400
User-agent: Mutt/

On Thu, May 12, 2011 at 03:13:51PM +0300, Petteri Räty wrote:
> Repeat-By:
>       address@hidden ~/test $ echo foo > a b

This one is not an error; it simply does not mean what you think it means.
The following commands are all equivalent:

echo foo > a b
echo > a foo b
> a echo foo b
echo foo b > a

In a simple command, the redirection is allowed to appear *anywhere*,
including in between arguments.

>       address@hidden ~/test $ multi="a b"
>       address@hidden ~/test $ echo foo > ${multi}
>       bash: ${multi}: ambiguous redirect

This one is different, because the redirection is parsed before
parameter expansion.  If you have a filename in a variable, and you want
to redirect to that filename, always quote it:

echo foo > "$multi"


reply via email to

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