Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Open Source > BOOK Beginning Linux Programming, 3rd Edition
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK Beginning Linux Programming, 3rd Edition
This is the forum to discuss the Wrox book Beginning Linux Programming, 2nd Edition by Richard Stones, Neil Matthew, Alan Cox; ISBN: 9780764543739
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK Beginning Linux Programming, 3rd Edition section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 27th, 2006, 09:56 AM
Registered User
Join Date: Sep 2006
Location: Los Angeles, CA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page 54: exec command rarely used?

The author states:

exec 3< afile
This causes file descriptor three to be opened for reading from file afile. It's rarely used.

I disagree with the author's opinion that it is rarely used. Opening up a file for reading is a very common occurence. True, programmers will try to use more specific commands, such as grep, to find the specific variable they are looking for in a file, but I won't say that opening a file in order to read line after line is rare. As far as I know, I don't know of any other way to open a file for sequential reading besides using this command combined with the read command.

Here is real life example:

exec 3< $temp_file
#read each line and make a directory for it
while read -u 3 comp; do
directory=$(echo $comp | tr -s '/')
mkdir $main_dir$(echo $comp | tr -s '/') 2> /dev/null

This line of code opens up the file reading and then read each line creating a directory with the string on each line.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Try It Out - Adding Formatted Text p. 54 gerry789 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 October 29th, 2011 11:17 AM
button command for page change Jonas Access 5 June 6th, 2007 11:39 AM
Ch2 52-54--passing session variables dprice BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 September 26th, 2005 07:01 AM
Command button not working in ms access page mohiddin52 Access 1 December 14th, 2003 06:52 PM

All times are GMT -4. The time now is 07:17 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.