that would generate a syntax error in shells on both Linux and on Solaris systems.
And, even if Solaris systems had a grep that supported the non-standard options provided as extension on Linux systems, you would also find that the sed commands you're using use extended regular expressions in the substitute commands (when the standards state that basic regular expressions are to be used there, and Solaris sed conforms to the standards and would generate bad BRE syntax errors). But by replacing both the one or two grep commands and both sed commands in your two pipelines with a single awk command as shown below:
printf "Solaris awk replacement for Linux pipeline:
grep -A1 '<name>user</name>' jdbc.xml|
grep -v '<name>user</name>'|
sed 's/\(<value>\|<\/value>\)//g'|
sed -e 's/^[ \t]*//'
"
/usr/xpg4/bin/awk '
c { gsub("[[:space:]]|<[/]value>", "")
print
c = 0
}
/<name>user<\/name>/ {
c = 1
next
}' jdbc.xml
printf "\nSolaris awk replacement for Linux pipeline:
rep -m 1 '</name>' jdbc.xml|
sed 's/\(<name>\|<\/name>\)//g'|
sed -e 's/^[ \t]*//'
"
/usr/xpg4/bin/awk '
/<\/name>/ {
gsub("[[:space:]]|<[/]*name>", "")
print
exit
}' jdbc.xml
we get code that would run more efficiently and faster on both Linux and Solaris systems.
Print lines above, below pattern-matched line (context, window); "only" string matching pattern
1) GNU grep -A -B; /usr/sfw/bin/ggrep on some Solaris
2) peg, a perl script, does not use "-o" like GNU grep;
allows -A, -B
http://www.cpan.org/authors/id/A/AD/ADAVIES/peg-3.10 (or later)
3) ack, a perl script, can use "-o" like GNU grep; allows -A, -B
https://metacpan.org/pod/distribution/ack/ack
4) cgrep does not use "-o" like GNU grep; allows -nline,
+nline for context like GNU grep -A, -B; matching can cross lines
http://sourceforge.net/projects/cgrep/
5) bool, prints context in bytes; matching can cross lines
6) greppm (xtcgrep), extension of CPAN grep; allow -C context; allows -o;
complicated calling sequence; http://freecode.com/projects/greppm
7) sift (aka "gogrep"), extremely fast grep work-alike, allows -A, -B, -C
can "-o" using "--replace", matching can cross lines
https://sift-tool.org/ (verified 2015.11.05)
8) ag, "The Silver Searcher", similar to, but faster than ack.
In Debian 8.4 repository, as "silversearcher-ag".
9) pt, "The Platinum Searcher", similar to ag, faster than ack.
https://github.com/monochromegane/the_platinum_searcher
Uses "-w" as in "grep "-o"; written in "go". (verified 2016.04.25)
Stand-alone codes can be placed in one's own "bin" directory and used just like system commands (provided the PATH contains that directory).