MACSCRPT Archives

August 2007

MACSCRPT@LISTSERV.DARTMOUTH.EDU

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

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

Print Reply
Subject:
From:
David Livesay <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 2 Aug 2007 21:06:53 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (25 lines)
Every example I've seen looks basically like this:

  for i in `cat somefile`
do
	echo $i
done

But this only works if the lines have no whitespace in them, which  
doesn't exactly describe most of the files I'm trying to work with  
(log files, to be specific), because i ends up being each word  
instead of each line.

I could pipe the output from cat to sed and replace the whitespace  
with a character not found in log files and then replace those  
characters with whitespace before processing them, but that seems  
like a waste of time to me. (Actually, that pretty much sums up my  
impression of shell scripting so far, but I have something I need to  
accomplish with it, unfortunately.)

BTW, can anyone recommend a good book on shell scripting for someone  
who doesn't intend to make a career of it--just get a few things  
done? I've done about all I can with man pages.

Thanks!

ATOM RSS1 RSS2