• 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: Chris Janton <email@hidden>
  • Date: Tue, 19 Apr 2005 06:40:30 -0700

The shell can't easily do string extraction by position, but it can certainly do it by matching and removing a known prefix or suffix.

x="nameOfSomeApp_log.txt"

Sure it can (bash in this example) it just needs to be specified properly.


To get the length of a string - ${#x}
To get everything but the last 8 characters  - ${x: 0: ${#x}-8}

That's STRING : offset : number of characters

You can read about it in the bash manual page (man bash). The example/description will confound you until you find out that its is better to put blanks in front of the parameters...I found this web page to be helpful

	http://ca.lxer.org/LDP/LDP/abs/html/string-manipulation.html

8)
----------------------------------
Chris Janton  - face at CentosPrime dot COM
Netminder for Opus1.COM

_______________________________________________
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


  • Follow-Ups:
    • Re: shell equivalent to text 1 thru -9?
      • From: Christopher Nebel <email@hidden>
    • Re: shell equivalent to text 1 thru -9?
      • From: "Mark J. Reed" <email@hidden>
  • Prev by Date: mysql blob
  • Next by Date: Antw.: Choose-your-own-adventure game
  • 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