shell中if else语句能否用一行命令实现吗?

图片说明

图示是一个if else语句,能用一行命令实现吗?能实现请给出答案,若不能请回答为什么?

图片说明

shell 三目操作符 试试吧 用来简化if else的

cmd = [-s "${sc_cmd}"] ? "sh $sc_cmd | tee -a ${file_log}/test2.log" : "exit 0"
$cmd