Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer > Re: using cat t...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 7 Topic 991 of 1040
Post > Topic >>

Re: using cat to get a list to for in sh or in ksh

by Robert Peirce <bob@[EMAIL PROTECTED] > Feb 7, 2008 at 02:34 AM

In article <fodebg$c4t$1@[EMAIL PROTECTED]
>,
 David Spencer <spencer@[EMAIL PROTECTED]
> wrote:

> Robert Peirce <bob@[EMAIL PROTECTED]
> writes:
> 
> >In sh and ksh, I have used
> 
> >   for i in `cat file`
> >   do
> >      do-something-with-$i
> >   done
> 
> >on other systems with no problem.  In OS X, this sometimes hangs, but 
> >sometimes it doesn't, which is very confusing.  Pr also hangs, but for 
> >some strange reason, head works in the same script!
> 
> Reading the whole file into one line exceeds the shell's line length
> limit.
> 
> It works on other systems because they have longer line-length limits.
> It's still a bad idea.
> 
> head(1) works because it's not reading the whole file.
> 
> The ksh(1) input mechanism is the read builtin, not cat(1).  RTFM
> ksh(1).

I am familiar with read and I have used it in more recent scripts.  This 
is an old one I thought would work and it didn't.  As a stopgap, I used 
split to break it into smaller files that I could read with cat until I 
get around to using read.

-- 
Robert B. Peirce, Venetia, PA  724-941-6883
bob AT peirce-family.com [Mac]
rbp AT cooksonpeirce.com [Office]
 




 7 Posts in Topic:
using cat to get a list to for in sh or in ksh
Robert Peirce <bob@[EM  2008-02-06 20:16:26 
Re: using cat to get a list to for in sh or in ksh
Robert Peirce <bob@[EM  2008-02-06 20:32:05 
Re: using cat to get a list to for in sh or in ksh
Robert Peirce <bob@[EM  2008-02-06 20:44:43 
Re: using cat to get a list to for in sh or in ksh
David Spencer <spencer  2008-02-06 23:03:12 
Re: using cat to get a list to for in sh or in ksh
Robert Peirce <bob@[EM  2008-02-07 02:34:48 
Re: using cat to get a list to for in sh or in ksh
Bob Harris <nospam.New  2008-02-07 01:25:23 
Re: using cat to get a list to for in sh or in ksh
David Spencer <spencer  2008-02-07 01:58:13 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 10:02:18 CST 2008.