Web Hosting Talk







View Full Version : Unix Text Extraction


azizny
11-01-2004, 07:59 PM
I have a list of files. which I need to extract All img src's (image links) from those files.

How would I do such thing in unix?


I know that I acn do $(var ## *x} , but how would I activate such thing with a loop?

Peace,

Jason-Hosts
11-01-2004, 08:06 PM
using str_replace ?

$blah = str_replace("<img src=", "", $blah);

xecl
11-02-2004, 01:48 AM
You could always use grep.

SimplyDiff
11-02-2004, 10:34 AM
I'm tired, so this may not work correctly, but you can try. It could be shortened in places, but....


perl -ne 'print join("\n",/<\s*img[^>]+src\s*=\s*"([^"]+)"/i). "\n"' LISTOFFILES | perl -pe 's/^\n//s'