bash:使用||和&&一起[重复]

问题描述 投票:0回答:1

是否有任何方法可以在单行命令中同时使用||&&

我正在尝试做相当于python的事情:

import os
doSomething() if os.system("[[ -f hello.txt ]]") else doSomethingElse()
bash
1个回答
0
投票

在您的python示例中没有“ AND”,在吗?

在bash中,我将其简单写为

if [ -f hello.txt ]; then
   doSomething
else
   doSomethingElse
fi
© www.soinside.com 2019 - 2024. All rights reserved.