• 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: shell equivalent to text 1 thru -9?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell equivalent to text 1 thru -9?


  • Subject: Re: shell equivalent to text 1 thru -9?
  • From: "Mark J. Reed" <email@hidden>
  • Date: Mon, 18 Apr 2005 16:45:00 -0400

Accidently hit send early.

On 4/18/05, Mark J. Reed <email@hidden> wrote:
If you really do want to do it by character position, it's doable, just ugly:

${x%${x#?????????}}


That is, you have to specify the number by counting '?'s - there are nine in the above example.  That reads as "Take the string and chop off whatever's left over after you chop off the first nine characters" - which therefore returns the first nine characters.  You can use this capability to write a substr() function that accepts numbers and builds and evaluates the _expression_ for you if it's something you find yourself needing on a frequent basis.  But I find that most of the time I'm parsing filenames based on delimiters (/, :, ., _) rather than known-length portions, and the ${x#prefix_to_remove} and ${x%suffix_to_remove} work very well for that.




--
Mark J. Reed <email@hidden>
 _______________________________________________
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

References: 
 >shell equivalent to text 1 thru -9? (From: Jake Pietrykowski <email@hidden>)
 >Re: shell equivalent to text 1 thru -9? (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: shell equivalent to text 1 thru -9?
  • Next by Date: Scripting in quark...
  • Previous by thread: Re: shell equivalent to text 1 thru -9?
  • Next by thread: Re: shell equivalent to text 1 thru -9?
  • Index(es):
    • Date
    • Thread