Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 at 18:49

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.