Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to extract range from IP= to TUAL_HOSTNAME_=, as below.

But its also extracting other match pattern for IP.

sed -i -e '/IP=/,/TUAL_HOSTNAME_=/{w /tmp/101' -e 'd}' /tmp/install;
#IP=
#AS_HOSTNAME=
#ASDM_USERID=
#ASRP_GROUPID=
#D_HOSTNAME=
#ASE_NODENAME=
#ASE_HOSTNAME=
#PP_NAME_1=
#USTER_NAME_1=
#NITIAL_HEAPSIZE_1=
#AX_HEAPSIZE_1=
#TUAL_HOSTNAME_1=
#
#
#
sed -i "s/^$IP\(.*\)$/$IP\1 $AS_HOSTNAME/" /etc/hosts;
#
#
#
#
sed -e '/PF/,/PF1/{w /tmp/wserver' -e 'd}' "$ASCRPT";

Is there a way to match exact pattern and extract it.

Thanks

Raajesh

share|improve this question
    
Hello and welcome to SuperUser. I can't really understand what you're trying to do. What is the code you posted? Could you post the text you want to match against, and the desired result? – m4573r Mar 7 '14 at 18:49

I noticed TUAL_HOSTNAME_= does not match the content. Also there is a semicolon missing after the d command. Try:

sed -i -e '/IP=/,/TUAL_HOSTNAME_[0-9]*=/{w /tmp/101' -e 'd;}' /tmp/install
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .