On Fri, 2008-03-07 at 11:59 -0500, Ross S. W. Walker wrote:
Ross S. W. Walker wrote:
Jerry Geis wrote:
Hi - I am not an expert at shell script writing. If /proc/cmdline looks like
option1 option2 ... ks=http://192.168.1.8/ks/ks.cfg option3 option 4 ...
How can I get the 192.168.1.8 out of this cmdline.
Try:
# IPADDR=`cat /proc/cmdline | sed 's/.*/([1-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*)/.*/\1/'`
This will find an IP in between /.../
Actually shorter sed line:
# IPADDR=`cat /proc/cmdline | sed 's/.*/([0-9]+.[0-9]+.[0-9]+.[0-9]+)/.*/\1/'`
And shorter still:
sed 's/.*/(([0-9]+.){3,}[0-9]+).*/\1/'
which uses {3,} to specify the 3 occurrences of [0-9]+.
However, I would simply go for something like:
sed 's,.*http://%5C(.*%5C)/ks/.*,%5C1,'
Jim