Chris Arnold wrote:
Using SLED SP1 and SED. I need to add some text before some existing text in 1
file, in about 100 different spots. The existing text is as follows:
<A onclick="window.open(this.href,'_blank');return false;"
HREF='/kjvdict/indexFRMB01C001.htm'>1</A>
The section of text above will differ in every line. So the section
indexFRMB01C001 will appear as indexFRMB01C002 on the next line and so on for
all 100 lines.
Randall S wrote a killer script that would add quotes to some text so i am
trying to modify that script and use it but not having much luck. Here is the
script:
#!/bin/sh
targetList=(
# ... or "ls":
$( ls *.php )
)
for target in "[EMAIL PROTECTED]"; do
sed \
--in-place= \
-e "1s;*.htm;'&';" \
"$target"
done
You can see that i am trying to use a wildcard in *.htm......Clearly, i don't
know what i am doing :) Can someone (nicely) help me with this?
You need to use regular expression syntax for wildcards. The dot (.)
character represents almost any character (newlines depending on
settings) and star represents 0 or more instances, so .*\.htm is the
regular expression syntax for the more familar form of *.htm that you
are thinking of. The backslash escapes the dot so \. means the actual
dot (period) character. I'm not too familiar with sed but I imagine
that this command
sed -i -e "s/.*\.htm/\&" file
will probably do what you want. -i is short for --in-place. Note that
.* greedily matches characters, except for new line, so this is only
going to match the first ".htm" it finds on a line. If you might have
more than one per line, you need to find some way to delineate the toke,
maybe if it is surrounded by whitespace or a quote or something. Also
note that the & character by itself will reference the matched text, and
the escaped & (\&) will be the actual & character, I assume that's what
you wanted.
I'm not sure of the semicolon syntax you have used, thus i have replaced
the semicolons with the standard forward slashes.
--Jason
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]