shell命令中“&&”的目的是什么?據(jù)我所知,&在命令之后使用是為了在后臺運行它。&用法示例:tar -czf file.tar.gz dirname &但是怎么樣&&?(看看這個例子:https://serverfault.com/questions/215179/centos-100-disk-full-how-to-remove-log-files-history-etc#answer-215188)
3 回答

慕桂英3389331
TA貢獻2036條經(jīng)驗 獲得超8個贊
&&
讓你根據(jù)上一個命令是否成功完成做一些事情 - 這就是你傾向于把它看作鏈接的原因do_something && do_something_else_that_depended_on_something
。

嗶嗶one
TA貢獻1854條經(jīng)驗 獲得超8個贊
此外,你還有||
一個邏輯或者,;
它也只是一個不關心命令發(fā)生的事情的分隔符。
$ false || echo "Oops, fail"Oops, fail $ true || echo "Will not be printed"$ $ true && echo "Things went well"Things went well $ false && echo "Will not be printed"$ $ false ; echo "This will always run"This will always run
有關此內(nèi)容的一些詳細信息,請參閱Bash手冊中的命令列表。
添加回答
舉報
0/150
提交
取消