File descriptors odd question
Hello all,
I'm reading a book on some interesting linux hacks and came across one that I'm slightly stumped on. I know about file descriptors 0, 1, and 2 (input, output, error) and how you can direct them to go down the same stream like so: command 2>&1 | ..... or var=`command 2>$1` but where I'm getting a bit confused is when they swap the descriptors using the mostly unused 3-9 FDs like so: command 3>&2 2>&1 1>&3 | .... Why would I want to swap file descriptors in the first place? Any practical examples? Also it mentions closing the extraneous FDs like so: 3>&~ , is this the correct format? doesn't ~ stand for the home directory? If anyone can shed some light on this I'd appreciate it. Thanks! |
Chapter 16 of the Advanced bash scripting guide explains it pretty well I think.
And the syntax for closing a file descriptor is 3>&- |
Well that would make a bit more sense to me :D
|
All times are GMT -5. The time now is 01:19 AM. |