Use sed to find and replace a url
Hello. Sed is a tough learn.
I need to take several files each with a bunch of urls in them and get rid of parts of the url. In the code of the files, it reads something to the effect of: Code:
<a href='http://www.yahoo.com/here-is-testpage-this-is-the-page.aspx'> Code:
testpage Code:
<a href='http://www.yahoo.com/ Code:
here-is- Code:
-this-is-the-page.aspx'> There must be a way to use sed. I want to write a few scripts to do this automatically so that i don't have to manually do this. (there are a lot of files to do this on) |
Something like this?
Code:
$ cat test.html Code:
find -type f -name \*.html -exec sed -r -i "s@^.+here-is-(.+)-this-is-the-page.aspx'>@\1@" {} \; all subdirs. Cheers, Tink |
You are the man! That worked exactly how i needed it. If only i understood why?
-Thanks |
It probably ain't "sed" that's the tough learn, it's regex.
Plenty of threads here recommending tutorials - but it's still a tough slog when you start. |
Quote:
Which bit is giving trouble? Happy to elaborate :} Cheers, Tink |
All times are GMT -5. The time now is 06:01 AM. |