Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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:

Code:
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.


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





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