LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-05-2011, 12:24 PM   #16
Trickie
Member
 
Registered: Sep 2004
Posts: 38

Rep: Reputation: 23

@grail - OK, two errors: the first is mine for missing the trailing dots in "file 1", the second is yours for mis-reading the spec.

Richard
 
0 members found this post helpful.
Old 04-05-2011, 02:04 PM   #17
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 147Reputation: 147
Cool

Quote:
Originally Posted by grail View Post
Your on
Very cool!

The only part I don't grok is this.

Code:
exec 3<file1 4<file2
...
exec 3<&- 4<&-
  • Is it truly necessary to call exec to acquire the desired FDs?
  • How can you safely assume FD 3 and FD 4 are free for use in any particular environment?
 
Old 04-05-2011, 07:10 PM   #18
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
Like FDs 0 (stdin), 1 (stdout), 2 (stderr), more FDs are avail at each shell invocation. It is hoped you know what your current prog/script has used/is using at any time.

Analogous to params $0, $1, $2 etc ...
 
1 members found this post helpful.
Old 04-06-2011, 03:28 AM   #19
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,504

Rep: Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893
Quote:
Is it truly necessary to call exec to acquire the desired FDs?
Happy to see an alternative. I will admit that I am at less than a year of experience with them so still learning.
Quote:
How can you safely assume FD 3 and FD 4 are free for use in any particular environment?
I guess you could make it more robust to check prior to running and use the first available ones, but:

1. Was only really looking at a simple solution
2. As with first answer, happy to know more ways to identify those in use and how to choose next ones
 
1 members found this post helpful.
Old 04-06-2011, 10:11 AM   #20
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 147Reputation: 147
Quote:
Originally Posted by grail View Post
happy to know more ways to identify those in use and how to choose next ones
Here's what I found.

Quote:
Originally Posted by Bash Reference Manual -> 3.6 Redirections
Redirections using file descriptors greater than 9 should be used with care, as they may conflict with file descriptors the shell uses internally.

http://www.gnu.org/software/bash/man...l#Redirections
 
  


Reply

Tags
awk, bash, paste


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Concatenate and labeling files wisnoskij Linux - Newbie 4 05-06-2010 06:58 AM
how to find some files and concatenate them? yumener Linux - Newbie 7 03-10-2009 03:41 PM
Script to concatenate several files docaia Linux - General 10 02-03-2008 01:59 PM
Concatenate PDF files? mykrob Linux - Software 5 11-07-2006 05:25 AM
concatenate binary files???? justin19fl Linux - Newbie 6 05-14-2001 02:13 PM


All times are GMT -5. The time now is 01:02 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration