sed exact match patterns of range and extract lines from thereon

0

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

user2692634

Posted 2014-03-07T17:13:18.550

Reputation: 29

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 – 2014-03-07T18:49:25.380

Answers

0

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

Scrutinizer

Posted 2014-03-07T17:13:18.550

Reputation: 249