Re: shell equivalent to text 1 thru -9?
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