LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 07-24-2012, 05:52 AM   #1
barry07
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Rep: Reputation: Disabled
Question Opening files as input in bashj


I want to use the text of a file as the input for a bash read command.

to use the -u option I need a file descriptor, presumbly this means I open the file and get a file descriptor. I have tried the reference manual, scripting guide and advance scripting guide, but have found no help.
So, how do I open a file?

barry
 
Old 07-24-2012, 06:15 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
is this what you are looking for: http://www.linuxquestions.org/questi...y-line-136784/ ?
 
Old 07-24-2012, 06:19 AM   #3
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
Maybe
Code:
while read VAR
do
	#play with $VAR
done < /path/to/file
is all you need...
 
Old 07-24-2012, 06:28 AM   #4
barry07
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for the replies. That would solve the immediate problem, but I want to know how to attach files to channels other than 0,1,2 (stdin, stdout, stderr) I can find everythin but how to open the files and attach them to a channel number.

Am I barking up the wrong tree?

Barry
 
Old 07-24-2012, 06:45 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
what do you mean by channel? how do you want to use those channels? What is your original goal with it?
 
Old 07-24-2012, 07:41 AM   #6
barry07
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks all. I have found the answer. Syntax is

3< filename

then read -u 3 line

that does me. Thanks everyone

Barry
 
  


Reply



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
Opening .db files m123 Linux - Newbie 3 09-29-2005 04:51 PM
Opening files Diederick Programming 5 06-27-2005 08:11 PM
Smart Common Input Method (SCIM) not opening a window? Erik_the_Red Linux - Software 2 06-11-2005 06:48 AM
Opening Input files with C++ in Linux MDBlueIce Programming 6 08-30-2004 05:38 PM
opening files... hoffman Linux - Newbie 10 11-13-2003 12:24 PM

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

All times are GMT -5. The time now is 12:25 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