How to say this in Bash?

Unga unga888 at yahoo.com
Mon May 25 14:36:46 UTC 2009


--- On Mon, 5/25/09, Matthew Seaman <m.seaman at infracaninophile.co.uk> wrote:

> From: Matthew Seaman <m.seaman at infracaninophile.co.uk>
> Subject: Re: How to say this in Bash?
> To: "Unga" <unga888 at yahoo.com>
> Cc: freebsd-questions at freebsd.org
> Date: Monday, May 25, 2009, 8:10 PM
> Unga wrote:
> > Dear all
> > 
> > This may be slightly OT, but I'm using on a FreeBSD
> machine. How
> > to convert following into bash style?
> > 
> > echo "${X}" > ${Z}
> > echo "${Y}" >> ${Z}
> > 
> 
> Exactly the same in posix standard /bin/sh or in
> bash.  bash(1) should
> be capable of running any compliant /bin/sh script
> directly.  The converse
> is not generally true, so for maximum portability write
> according to sh(1)
> and avoid bash-isms.
> 
> If you're asking about converting csh to bourne shell, then
> that's a whole
> other kettle of fish.  The echo commands above just
> happen to be the same in
> either language, but that's one of the few points of
> confluence between the
> two.  Typically you'ld have to know both languages and
> laboriously translate
> between them.
> 

Here is what happens in bash shell:
$ echo "${X}" > ${Z}
bash: ${Z}: ambiguous redirect

Best regards
Unga



      


More information about the freebsd-questions mailing list