Re: text item delimiter
Re: text item delimiter
- Subject: Re: text item delimiter
- From: "Steven D.Majewski" <email@hidden>
- Date: Fri, 29 Apr 2005 13:25:13 -0400
On Apr 29, 2005, at 1:12 PM, Ruby Madraswala wrote:
Please bare with my ignorance, I have never used "sed" before -
type 'man sed' in terminal.app window.
sed-e 'y/abcdefghi/123456789/' " &
what does y stand for?
[ "sed-e" above should be "sed -e" ]
(from 'man sed': )
[2addr]y/string1/string2/
Replace all occurrences of characters in string1 in the
pattern
space with the corresponding characters from string2. Any
char-
acter other than a backslash or newline can be used
instead of a
slash to delimit the strings. Within string1 and string2,
a
backslash followed by any character other than a newline
is that
literal character, and a backslash followed by an ``n'' is
replaced by a newline character.
And
"-e 's/j/10/g' " & ¬
what does g stand for?
[2addr]s/regular expression/replacement/flags
Substitute the replacement string for the first instance
of the
regular expression in the pattern space. Any character
other
than backslash or newline can be used instead of a slash to
delimit the RE and the replacement. Within the RE and the
replacement, the RE delimiter itself can be used as a
literal
character if it is preceded by a backslash.
But note that the solution below seems to be doing the opposite of what
you originally asked:
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.........................
You asked about replacing numbers with letters.
Script below is replacing letters 'a-z' with numbers 1-26.
If what you asked above is accurately what you want,
then use: "tr '1-9' 'a-i' " for the shell script.
( see "man tr" )
-- Steve Majewski
Thanks
Ruby
-----Original Message-----
From:
applescript-users-bounces+rubym=email@hidden
[mailto:applescript-users-
bounces+rubym=email@hidden] On Behalf Of
Gnarlodious Lists
Sent: Friday, April 29, 2005 12:23 PM
To: Applescript
Subject: Re: text item delimiter
Entity Rob Stott spoke thus:
...theres almost certainly a better way that doesn't involve that
many 'sed's
for multiple digits but I'm not sure how.
do shell script "cat " & theFile & " | sed-e 'y/abcdefghi/123456789/'
" & ¬
"-e 's/j/10/g' " & ¬
"-e 's/k/11/g' " & ¬
"-e 's/l/12/g' " & ¬
"-e 's/m/13/g' " & ¬
"-e 's/n/14/g' " & ¬
"-e 's/o/15/g' " & ¬
"-e 's/p/16/g' " & ¬
"-e 's/q/17/g' " & ¬
"-e 's/r/18/g' " & ¬
"-e 's/s/19/g' " & ¬
"-e 's/t/20/g' " & ¬
"-e 's/u/21/g' " & ¬
"-e 's/v/22/g' " & ¬
"-e 's/w/23/g' " & ¬
"-e 's/x/24/g' " & ¬
"-e 's/y/25/g' " & ¬
"-e 's/z/26/g' "
-- Gnarlie
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to 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:
email@hidden
This email sent to email@hidden
-- 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