[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/1.4.2.3i |
On Thu, May 12, 2011 at 03:13:51PM +0300, Petteri Räty wrote:
> Repeat-By:
> betelgeuse@pena ~/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.
> betelgeuse@pena ~/test $ multi="a b"
> betelgeuse@pena ~/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"
Always.