![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep question. | saurabhsinha23 | UNIX for Dummies Questions & Answers | 3 | 12-10-2007 09:58 PM |
| grep question | tim-bobby | UNIX for Dummies Questions & Answers | 4 | 10-05-2007 08:58 AM |
| Question about GREP | Adriel | UNIX for Dummies Questions & Answers | 16 | 03-22-2007 04:03 AM |
| Another grep question | kingdbag | UNIX for Dummies Questions & Answers | 6 | 10-26-2006 10:56 PM |
| Grep question | eloquent99 | UNIX for Dummies Questions & Answers | 4 | 02-20-2003 06:49 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
grep & sed question
I'm trying to write a bash script to perform a tedious task, but I have no experience and hardly any knowledge so I've been having a rough time with it.
I'm on Mac OS X, and I want a script to do the following: I have a directory that has about 200 sudirectories. In each of these directories, there are a number of html files that each include a relative link to an image. What I want to do is create one html file that contains all the img tags of all the html files in all the sudirectories. I would also like to turn all the relative links into absolute ones (meaning: I want each src attribute to contain the full path on my system of the html file -and image, they are in the same directory-). I've been at it with sed, but one of the problems seems to be that some of the html files don't have regular UNIX line endings, so it's kind of hard for me to extract just those line with img files (I get the full files), let alone img tags. What I've been toying with is the following (where you'll see that I try to put some line endings back where I think they'd be useful - though for some reason it doesn't work as expected): #!/bin/bash for pic in ./advanced/*/image??.html do grep img $pic | sed "s/img/img\ /" | cat >> images.html done This script doesn't address the absolute link problem yet. Any help would be greatly appreciated. Last edited by der Kopf; 11-20-2004 at 01:00 AM. |
| Forum Sponsor | ||
|
|
| Thread Tools | |
| Display Modes | |
|
|