• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Count lines
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Count lines


  • Subject: Re: Count lines
  • From: Paul Berkowitz <email@hidden>
  • Date: Fri, 12 Nov 2004 17:29:07 -0800

On 11/12/04 3:35 PM, "Chris Espinosa" <email@hidden> wrote:

> On Nov 12, 2004, at 2:04 PM, Paul Berkowitz wrote:
>
>> In this particular case, all I want is the number of lines, not the
>> file
>> name which wc -l adds on to the end. I guess you could remove that
>> with a
>> grep. Gnarlodius sent me:
>>
>> do shell script "sed -n '$=' /SystemProfile.txt"
>>
>> which works perfectly. (In fact it gives the answer "1" when there's a
>> Mac
>> file with no LFs. whereas wc -l says the answer is "0", which is
>> interesting.)
>
> If you want to handle both Mac and Unix files, use tr:
>
> cat ./SystemProfile.txt | tr \r \n | wc -l

That doesn't work when I have Windows files: it inserts an extra blank line
for the CR part of the CRLF. The whole point of what I'm doing here is to
see if there's more than 1 LF-delimited "line" in the file: if there is,
then it's a Windows or Unix file and further sed operations will work on it.
If it's a Mac file that has only one "line" (as far as sed is concerned),
_that's_ when I need to replace \r with \n before I can proceed. I
especially do not want to do the \n replacement for Windows files.

I've got it all working now.

--
Paul Berkowitz


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Count lines
      • From: "John C. Welch" <email@hidden>
References: 
 >Re: Count lines (From: Chris Espinosa <email@hidden>)

  • Prev by Date: Re: logging to a file?
  • Next by Date: Re: Count lines
  • Previous by thread: Re: Count lines
  • Next by thread: Re: Count lines
  • Index(es):
    • Date
    • Thread