[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] command as argument for grep



Contains spoilers ... or rather, a possible solution. sed and awk is the
way to go, and is what I've used below ... just using one of these. If ye
want to have a crack before seeing my method, stop reading now, else scan
past your paragraph ... :-)


> 
> I've now got a list of files updated today and want to wget them.  (wget
> created the index.html file)  I tried wget with -B to specify the base
> url, -F to force html and -i to use the file I'd created using the grep
> command above.  However wget just returned no "relative urls found in file".
> So I now need to extract a list of files from the lines I got from grep.
> Preceding every filename is href=" and following every file is ">.  In perl
> I'd use split but I'm still getting away with using a shell script here so I
> have a feeling I need sed or awk to extract the filenames.  Am I correct in
> chasing down this route?
> 

On the assumption that it's one entry per line, then, given your description
above, I'd suggest (all untested):

	sed -e 's/.*href=// -e 's/>.*//' < input > output

Or you may need to escape the > in sed:

	sed -e 's/.*href=// -e 's/\>.*//' < input > output

Chris...

-- 
\ Chris Johnson           \
 \ cej [at] nightwolf.org.uk    ~-----,   
  \ http://cej.nightwolf.org.uk/  ~-----------------------------------, 
   \ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____
___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.