• 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 word's occurences
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Count word's occurences


  • Subject: Re: Count word's occurences
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 08 Sep 2014 12:43:04 -0500

On Sep 08, 2014, at 10:22, Christopher Stone <email@hidden> wrote:
When run from a 10,000 word file or BBEdit window using your example words the run-time is less than 2/10 of a second on my system.
______________________________________________________________________

Hey Guido,

Oh, yeah.  If you want to run a TextWrangler text filter you can do this.  It's just about instantaneous on the same 10K word test file.

Remember that text filters are destructive, so if you want to keep the original be sure to run on a copy.

--
Best Regards,
Chris

#! /usr/bin/env bash

T=$(tr '\r' '\n');
S=$(sort -u <<< "$T");
A="";

for i in $S
 do
X=$(grep "$i" <<< "$T" | wc -w);
A="$A$i $X\n";
 done

echo -e "$A" | column -t;

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Count word's occurences
      • From: Christopher Nebel <email@hidden>
    • Re: Count word's occurences
      • From: Guido Tangorra <email@hidden>
References: 
 >Count word's occurences (From: Guido Tangorra <email@hidden>)
 >Re: Count word's occurences (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Count word's occurences
  • Next by Date: OT: Count word's occurrences
  • Previous by thread: Re: Count word's occurences
  • Next by thread: Re: Count word's occurences
  • Index(es):
    • Date
    • Thread