Using 'sed' to alter file
Using 'sed' to alter file
- Subject: Using 'sed' to alter file
- From: Mark Walsh <email@hidden>
- Date: Thu, 06 Apr 2006 13:48:36 -0400
I am fairly new to shell scripting, but have been picking up bits and pieces
here and there. Now I have a task which I'm having a little trouble working
out.
I need to change all characters which are not alphanumeric or ":" in certain
portions of a document to a dash "-". In other scripts where I have to
change file names similarly, I have used the following
do shell script "echo -n " & quoted form of TheFileName & " | tr -Cu
'[:alnum:]:' '-'"
And that works well. In the documents I need to change, I need to change the
characters that are between (but not including) "StringA" and "StringB" and
also all of the characters between (but not including) the first set of
parentheses after "StringC" (there are an unknown amount of characters
between "StringC" and the parentheses)
So far, the closest I have come to the first scenario is the following
sed -e '/StringA/,/StringB/ s/" & " " & "/" & "-" & "/g' < " & quoted form
of TheFile & "> " & quoted form of thenewfile
But that only changes spaces, and changes too much of the text before and
after the "StringA" and "StringB"
With my limited knowledge of sed (and almost non-existent knowledge of
regular expressions), it's been a struggle to get past my current progress.
I am hoping that there is someone out there who can help me get this
working. I hope I have given enough information to describe my problem, but
if not, please let me know.
Thanks in advance
Mark
_______________________________________________
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