LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-12-2003, 06:45 PM   #1
ferreter
Member
 
Registered: Oct 2002
Location: USA, IL
Distribution: Debian/Gentoo/Slack
Posts: 215

Rep: Reputation: 30
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!
 
Old 02-13-2003, 05:13 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Chapter 16 of the Advanced bash scripting guide explains it pretty well I think.

And the syntax for closing a file descriptor is 3>&-
 
Old 02-13-2003, 10:21 AM   #3
ferreter
Member
 
Registered: Oct 2002
Location: USA, IL
Distribution: Debian/Gentoo/Slack
Posts: 215

Original Poster
Rep: Reputation: 30
Well that would make a bit more sense to me
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Increasing File Descriptors Geoffrey_Firmin Slackware 5 04-21-2008 09:48 AM
Socket File Descriptors for a process MadCoder77 Linux - Networking 0 05-26-2005 04:19 PM
file descriptors node047 Linux - Newbie 1 03-29-2005 05:47 AM
unix file descriptors versus c FILE pointers nodger Programming 9 11-25-2004 07:02 AM
File Descriptors - How to raise the limit? xmdms Linux - General 3 07-15-2004 12:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration