LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 06: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, 07:15 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

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

Rep: Reputation: 186Reputation: 186
Maybe
Code:
while read VAR
do
	#play with $VAR
done < /path/to/file
is all you need...
 
Old 07-24-2012, 07: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, 07:45 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
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, 08: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


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


All times are GMT -5. The time now is 12:49 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration