Re: Count lines
Re: Count lines
- Subject: Re: Count lines
- From: "John C. Welch" <email@hidden>
- Date: Fri, 12 Nov 2004 19:41:02 -0600
On 11/12/2004 19:29, "Paul Berkowitz" <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.
This is why I pay for BBEdit. Click the button, read the number.
john
--
Head wounds do tend to bleed a lot. DonĀ¹t panic.
_______________________________________________
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