• 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: text item delimiter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text item delimiter


  • Subject: Re: text item delimiter
  • From: "Steven D.Majewski" <email@hidden>
  • Date: Fri, 29 Apr 2005 11:36:54 -0400


On Apr 29, 2005, at 10:54 AM, Rob Stott wrote:


On 29 Apr 2005, at 15:25, Ruby Madraswala wrote:

 Is this doable using text item delimiters, I tried it's not working. All I want to do is search a text file replace all occurrence of 1 to a, 2 to b.........................
I wouldn't do it using TIDs. Here's how I'd do it ...

tell application "Finder"
    set theFile to quoted form of (POSIX path of (choose file))
end tell

set theResult to do shell script "cat " & theFile & " | sed 'y/abcdefghi/123456789/' | sed 's/j/10/g' | sed 's/k/11/g' | sed 's/l/12/g' | sed 's/m/13/g'  | sed 's/n/14/g'  | sed 's/o/15/g'  | sed 's/p/16/g'  | sed 's/q/17/g'  | sed 's/r/18/g'  | sed 's/s/19/g'  | sed 's/t/20/g'  | sed 's/u/21/g'  | sed 's/v/22/g'  | sed 's/w/23/g'  | sed 's/x/24/g'  | sed 's/y/25/g'  | sed 's/z/26/g'"

...theres almost certainly a better way that doesn't involve that many 'sed's for multiple digits but I'm not sure how. Can anyone put me straight on that one?


It wasn't clear from the original question if the poster wanted multiple digit replacement or not.
( And if he does: what should "123" be replaced by ? )


I assumed all he wanted/needed was:
	  do shell script "cat " & theFile & "| tr '1-9' 'a-i' "


-- Steve Majewski - University of Virginia Alderman Library

_______________________________________________
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


  • Prev by Date: Re: text item delimiter
  • Next by Date: Re: Image upload via FTP
  • Previous by thread: Re: text item delimiter
  • Next by thread: RE: text item delimiter
  • Index(es):
    • Date
    • Thread