MACSCRPT Archives

August 2007

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 4 Aug 2007 00:43:02 -0400
Content-Disposition:
inline
Reply-To:
Macintosh Scripting Systems <[log in to unmask]>
Subject:
MIME-Version:
1.0
Content-Transfer-Encoding:
7bit
In-Reply-To:
Content-Type:
text/plain; charset=UTF-8
From:
"Mark J. Reed" <[log in to unmask]>
Parts/Attachments:
text/plain (15 lines)
Ah, there were no details.  Very well.  The most general bash idiom
(also works in ksh):

exec 3<"$filename"                   # open the file
while IFS= read -r -u3 line; do
    # do stuff with "$line" here
done
exec 3<&-                                # close the file

You can also just use input redirection on the whole loop (while...
do;...done <filename), but the exec method is the most flexible.

The IFS= disables whitespace separation so that whitespace in the
lines, even leading space, is preserved.

ATOM RSS1 RSS2