Sometime just before Sunday 28 April 2002 04:30 pm Kahli R. Burke Wrote
about:[EUG-LUG:2456] Re: asynchronous file access: ? use chattr +S ?
I tried it. It worked.. It will work on one file at a time, and Ill need to 
use a tmpfile as in
  cat file.html | perl -ne 's/alt\s*=\s*"(.*?)"/alt="$1" title="$1"/; print' 
> tmp.html;mv tmp.html file.html

I should be able to make a script to do all the files in the directory... Ill 
see if i can modify it to do other things too... 

Thanks!

Jamie

: Linux Rocks ! wrote:
: >     I do have a question about grep and stuff... I would like to replace text
: >with different text (like change alt= tags to title= or duplicate alt tags
: > to title tags... so, If i have something like
: >
: >
: >and I want
: ><a href="www.rocksolidnetworks.com"><img src="rock.jpg" alt="picture of
: > rock" title="picture of a rock"></a>
: >
: >What is the easiest way (yes, I could read awk, and sed and grep...) but I
: >basicly just want a rename for inside files (not just filenames).
:
: Both vi and emacs provide a regular expression replace mechanism.  In
:
: vi, try:
: :%s/<regex to find>/<replacement>/g
:
: (Note that the command starts with a colon)
:
: I'n emacs, it's C-M-%, or access it from the edit menu.
:
: When I want to do something more sophisticated, I'll usually write a
: quick Perl script (or one-liner), which is how I would do what you want
: above:
:
: cat file.html | perl -ne 's/alt\s*=\s*"(.*?)"/alt="$1" title="$1"/; print'
:
: This says:  cat the file into perl, and for each line (-n option),
: evaluate (-e option) the script in the single quotes:
:
: susbstitute(s/<regex>/<replacement>/):
:     alt<optional whitespace>=<optional whitespace>"<any character in
: between the quotes, save it in $1>"...
: replace with:
:     alt="<whatever matched in the parentheses" title="<whatever matched
: in the parentheses"
:
: print the altered string (to stdout)
:
: Try it and see if it works for you... You can do the same stuff with sed
: or awk.
:
: Kahli

-- 
for setting/changing your eug-lug mailinglist subscription use this website:
http://wWw.RockSolidNetworks.com/eug-lug.html
no microsoft products were used to produce this message.

Reply via email to