Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
180 views
in Technique[技术] by (71.8m points)

linux - mulitple commands in back tics


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Two possible paths here: split the command into two parts, and use BASH to compare, or write a composite line. Either way, better to use the $(command) instead of backticks.

Splitting the command

SVC_VER=$(getserversion.py)
CLI_VER=$(getcliversion.py)
if [ "$SVC_VER" = "$CLI_VER" ] ; then
   ...
fi

Or, combining them into single command line

MATCH=$(getversions.py | grep $(getcliversion.py))

Note that it's not possible to use the backticks for the second command, as the back ticks do not support nesting of commands.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...