URL: http://www.math.fu-berlin.de/~guckes/sed/ Created: Sun Aug 18 18:18:18 CET 1996 Last update: Tue Jun 06 12:00:00 MET DST 2000
IN: 1234567890123456 abcdefghijklmnop The quick brown OUT: 123|456789|01|23456 abc|defghi|jk|lmnop The| quick| b|rown
sed -n
's/[^0-9]*\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*/\1/p'
infile > outfile
string read as explanation s "substitute" / delimiter start of pattern [^0-9]* non-digits need not be anchored to '^'; use of ".*" would take away from the following digits! \( "start group" - start of IP number [0-9]\{1,3\} a number at least one, at most three digits \. a literal dot seperating the numbers [0-9]\{1,3\} a number at least one, at most three digits \. a literal dot seperating the numbers [0-9]\{1,3\} a number at least one, at most three digits \. a literal dot seperating the numbers [0-9]\{1,3\} a number at least one, at most three digits \) "end group" end of IP number .* "everything" this should match the rest of the line / delimiter separates input pattern from substitution pattern \1 first group references the matched first group this should contain the IP number / delimiter separates input pattern from p "print" prints the output pattern (default)
Here it is:
Again, this is fairly simple:
tr -d \\012 < bar
sed 3.0 has been withdrawn from distribution. It has major revisions, which mostly seem to be improvements; but it turns out to have bugs too which cause trouble in some common cases. Tom Lord won't be able to work fixing the bugs until May [1996?]. So in the mean time, we've decided to withdraw sed 3.0 from distribution and make version 2.05 once again the recommended version.
psed109.zip B 62423 960101 sed binary for NT/PowerPCTODO