LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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: 148Reputation: 148
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
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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: 148Reputation: 148
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:01 PM.

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