• 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: "Lanphier, Daniel A." <email@hidden>
  • Date: Mon, 08 Sep 2014 15:57:30 +0000
  • Thread-topic: Count word's occurences

APPLE=`grep -i apple FILENAME|wc –w`

BANANA=`grep -i  banana FILENAME|wc –w`

echo “Apple ${APPLE}”

echo “Banana ${BANANA}”

 

 

 

Dan Lanphier
Systems Engineer • Systems Operations
w: 402.498.1567
| m: 402.680.0613

This message is privileged and confidential and is intended only for the use of the addressee. Unauthorized use of this message is strictly prohibited. If you received this transmission in error, please immediately contact the sender and destroy the message. Thank you.

 

 

From: applescript-users-bounces+daniel.lanphier=email@hidden [mailto:applescript-users-bounces+daniel.lanphier=email@hidden] On Behalf Of koenig.yvan
Sent: Monday, September 8, 2014 10:35 AM
To: liste AppleScript US
Subject: Re: Count word's occurences

 

 

Le 08/09/2014 à 16:15, email@hidden <email@hidden> a écrit :



Hi Yvan,

 

Retype the minus, don't copy and paste the version from Dan.

 

Best regards,jan

     

 

Thanks to you and to Christopher.

I didn’t took care that the minus character wasn’t a true one.

After correcting that, the script works but I’m puzzled (it seems that i'm becoming accustomed to that).

When the text file contains :

 

-----------

apple 

grapevine

banana 

ananas 

orange 

apple 

apple 

orange 

--------------

if the keyword is grape the returned value is 1 which I don't really like but not the worse.

if the keyword is apple, the returned value is 3 which is OK.

 

If the text contains :

-----------

apple 1

grape 1

banana 1

ananas 1

orange 1

apple 2

apple 3

orange 2

--------------

 

if the keyword is grape the returned value is 2 which is at least surprizing.

if the keyword is apple, the returned value is 6 which is at least surprizing.

 

I paste the used code in case there is an odd character again.

set leFichier to (path to desktop as text) & "forGrep.txt"

set theKey to "grape"

 

do shell script "grep " & theKey & space & (quoted form of POSIX path of leFichier) & "|wc -w"

 

It seems that grep is difficult to understand for the old ape which I am.

 

Yvan KOENIG (VALLAURIS, France) lundi 8 septembre 2014 17:34:19

 

 

 

 

 _______________________________________________
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: "koenig.yvan" <email@hidden>
References: 
 >Count word's occurences (From: Guido Tangorra <email@hidden>)
 >RE: Count word's occurences (From: "Lanphier, Daniel A." <email@hidden>)
 >Re: Count word's occurences (From: "koenig.yvan" <email@hidden>)
 >Re: Count word's occurences (From: "email@hidden" <email@hidden>)
 >Re: Count word's occurences (From: "koenig.yvan" <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