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;
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.



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 .