Thanks dennis.jacob and zaxxon for your time to help me. I am newbie in awk/sed/perl one liner world so unable to understand error on your solution.
I tried SED command as suggested but getting below error.
server:/home> sed '/ListenPort/{ n; s/21111/98765/ }' /tmp/xp.xml
sed: command garbled: /ListenPort/{ n s/21111/98765/ }
I tried AWK command as suggested but getting below error.
server:/home> awk 'f==1 {gsub(/21111/,"98765");f=0; } /ListenPort/ {f++}1' < /tmp/xp.xml > /tmp/xp1.xml
awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1
---------- Post updated at 12:04 PM ---------- Previous update was at 09:40 AM ----------
I need to find variable "ListenPort" in line and then replace next line's 21111 to 98765.
And, this problem is not to solve only one string "21111" but it can be any number between "0-99999". It means displayed problem has 21111 but it could be 1 or 23 or 456 or 7890 or 98711. The good part is starting position of first number is always fixed in that line. It means number always start from position 17 and has surrounded by """ string.
Please help me to solve this problem using sed/awk/perl.
I posted you another version of the sed where every subcommand is in a separate line since older versions of sed do not support writing everything in the same line without ^J for example.
So take the sed script that is more than one line into a script and try it again.
Also I asked you to use code tags - the PM you got explains it very well - you got another one.
dennis' awk might need another version of awk so you might check if you have gawk or if you are on Solaris check for nawk.