![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Ubuntu costumized like OSX glitch | Texasone | Ubuntu | 5 | 06-16-2008 05:22 PM |
| Commentary: ISO should kick OOXML off the standards bus | iBot | UNIX and Linux RSS News | 0 | 01-26-2008 10:30 AM |
| Kick off Application on PC from Sun | vbshuru | UNIX for Advanced & Expert Users | 9 | 11-21-2003 12:37 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
need a little kick with sed, got it almost but on glitch
hi friends. yo i have a textfile with urlīs in it sometimes middle in text, sometimes one url alone is a line i append a string right behind the domain name so that http://unix.com becomes http://unix.com.APPENDTHIS on all occasions. i use this sed-line to achieve this: Code:
sed -i "s/http:\/\/[a-zA-Z0-9\_\-\.]*/&.APPENDTHIS/g" FILE now my problem is when the url contains a dash it messes up. test input file: Code:
http://alf.com/super.cgi http://frederick.xoom.com/homepage/xy.htm http://james_007.web1000.com/ http://unix-windows.com/bluescreen.txt Code:
http://alf.com.APPENDTHIS/super.cgi http://frederick.xoom.com.APPENDTHIS/homepage/xy.htm http://james_007.web1000.com.APPENDTHIS/ http://unix.APPENDTHIS-windows.com/bluescreen.txt the last url with the - dash in it messes up. it appends "APPENDTHIS" after the dash instead there where the domain-name ends. what do i do wrong? i tried to unescaped dash and double escaped also. thanks for the needed kick. |
|
||||
|
as so soften when i request help on here, i find the solution myself old: Code:
sed -i "s/http:\/\/[a-zA-Z0-9\_\-\.]*/&.APPENDTHIS/g" FILE new, working: Code:
sed -i "s/http:\/\/[a-zA-Z0-9\_--\.]*/&.APPENDTHIS/g" FILE instead of escaping the dash i have to double it. dont know why, just tested some variations and this one works. anyone any comment why? |
|
||||
|
thanks Tytalus, nice one thats what i call a fast answer ![]() ![]() ![]() ![]() this only works when the domain is trailed by a slash unix.com/ but not with unix.com but i found a workaround now. Code:
sed -i "s/http:\/\/[-a-zA-Z0-9\_\.]*/&APPENDTHIS/g" this one works smooth wherever the pattern occurs, wheter a linebreak follow or binary. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|