On Sun, Oct 19, 2003 at 11:37:44AM +0100, Dave selby wrote: > I need to get the contents of a HTML title tag & put it in a string. > > ie > <title>specialist cards</title> > > I need the "specialist cards" in a variable $titlecontents > I thought it would be easy with sed > > sed -n '/<title>/,/<\/title>/p' > > But no go. I have tried various ways but to no avail. > > Any ideas ?
In perl: #!/usr/bin/perl while(<>) { s/<title>//; s/<\/title>//; print; } or in a one-liner: perl -e 'while(<>){s/<title>//;s/<\/title>//;print;}' or using the -n option to make the while(<>){} implicit: perl -ne 's/<title>//;s/<\title>//;print;' or using the -p option that also makes the print implicit (like sed: perl -pe 's/<title>//;s/<\/title>;' Hope that helps, Bijan -- Bijan Soleymani <[EMAIL PROTECTED]> http://www.crasseux.com
signature.asc
Description: Digital signature