home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] can anyone explain bash "{fd}" file descriptor notation?

  • Subject: Re: [OCLUG-Tech] can anyone explain bash "{fd}" file descriptor notation?
  • From: Joe Burpee <jeb [ at ] burkby [ dot ] com>
  • Date: Mon, 5 May 2014 09:33:04 -0400
On Mon, May 05, 2014 at 05:40:03 -0400, Robert P. J. Day wrote:
> 
> $ echo test2 >&${foofd}
> $ cat /tmp/foo.out
> test1
> test2
> $
> 
> it *appends* to the file, which is not what i was expecting.
 
I'm guessing you were expecting the fd to be automatically closed, but I
don't think that would make much sense.

Close fd:
$ {foofd}>&-

Allocate fd:
$ {foofd}>/tmp/foo.out

Write to fd:
$ echo test3 >&$foofd

$ cat /tmp/foo.out
test3

Joe