我目前正在运行这个脚本,它适用于除一个以外的所有实例:
#!/bin/sh
pdfopt test.pdf test.opt.pdf &>/dev/null
pdf2swf test.opt.pdf test.swf
[ "$?" -ne 0 ] && exit 2
在上面的代码之后要执行更多行......
如果“pdf2swf test.opt.pdf test.swf
”失败,我该如何更改此脚本以运行“pdf2swf test.pdf test.swf
”?如果第二次尝试失败,那么我将“exit 2
”。
谢谢
最佳答案
短路“或”应该做你想做的:
pdf2swf test.opt.pdf test.swf || pdf2swf test.pdf test.swf
关于linux - Shell - 失败时运行附加命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2653483/