Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sed question? 1

Status
Not open for further replies.
May 29, 2003
40
US
could someone explain to me how this sed work?

sed 's/^.*src: \([^;]*\);.*/\1/'

particular what every sighn/operator mean or do?
thanks.
 
get whatever is beween a 'src: ' and a trailing ';'

sed 's/^.*src: \([^;]*\);.*/\1/'

s - for 'Substitute'
/..../ - pattern to match
^ - beginning of the line
.* - any character repeated 0 or more times
src: - a string 'src: '
\(....\) - FIRST 'capture'
[^;]* - any character BUT ';' repeated 0 or more times
; - a single ';' character
.* - any character repeater 0 or more times

/\1/ - print the FIRST 'capture'

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
its really true, this sed supposed to catch the words between &quot;src:&quot; to the first &quot;;&quot; but still i can't understand why the &quot;.*&quot; is nesseccary in this part &quot;\);.*/\1/'&quot;? why &quot;;&quot; only is not enough and we should add the &quot;.*&quot; both ?

thaks allot again for your lecture, you really helped.
 
The &quot;.*&quot; is necessary to ignore the characters after the &quot;;&quot;

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top