• 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: Help with simple grep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with simple grep


  • Subject: Re: Help with simple grep
  • From: Axel Luttgens <email@hidden>
  • Date: Fri, 29 Aug 2008 23:39:58 +0200

Le 29 août 08 à 20:28, Joe a écrit :

At 2:16 PM -0400 8/29/08, Mark J. Reed wrote:
In this case, however, all you have to do is supply the "-raw" option
to mdls, and you don't need grep at all.

Yep, that did it. Thank you very much.

Hello Joe,

This solved your problem, but hasn't explained the negative result you got, nor provided an answer to your other question: "The only reference for grep I have is the chapter in the BBEdit manual v6. Could you also suggest a good reference for grep?".

So, if you allow, THE reference for grep is in it's man page (in Terminal.app, just execute "man grep").

With that info, as well as with Mark's comment ("[0-9]* matches the empty string"), it appears that one needs to match at least one digit; Mark suggested one way to avoid the problem:
grep -o '[0-9][0-9]*'
That is, one is requiring to match one digit, followed by zero, one or more digits.
Another option is to make use of the "+" symbol, which means "one or more"; but it is only known in the "extended" version of regular expressions (other man pages refer to that syntax as "modern" RE); so, the following piece of code should do the trick too:
grep -oE '[0-9]+'


As a result, assuming x contains the posix path of the file you are interested in,

do shell script "mdls -name kMDItemPixelHeight " & quoted form of POSIX path of x & "| grep -oE '[0-9]+'"

should provide you with the info you are looking for.
At least, it does here. ;-)

HTH,
Axel _______________________________________________
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: Help with simple grep
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: Help with simple grep (From: "Mark J. Reed" <email@hidden>)
 >Re: Help with simple grep (From: "Mark J. Reed" <email@hidden>)
 >Re: Help with simple grep (From: Joe <email@hidden>)

  • Prev by Date: Re: Help with simple grep
  • Next by Date: Get sender in Apple Mail
  • Previous by thread: Re: Help with simple grep
  • Next by thread: Re: Help with simple grep
  • Index(es):
    • Date
    • Thread