RE: parsing /proc/cmdline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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://\(.*\)/ks/.*,\1,'

Jim


_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux