“&&"的目的是什么?在一个shell命令? [英] What is the purpose of "&&" in a shell command?

查看:77
本文介绍了“&&"的目的是什么?在一个shell命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,在命令后使用&在后台运行它.

As far as I know, using & after the command is for running it in the background.

&用法示例:tar -czf file.tar.gz dirname &

但是&&呢? (请看以下示例: https://serverfault.com/questions/215179/centos-100-disk-full-how-to-remove-log-files-history-etc#answer-215188 )

But how about &&? (look at this example: https://serverfault.com/questions/215179/centos-100-disk-full-how-to-remove-log-files-history-etc#answer-215188)

推荐答案

&&可让您根据上一个命令是否成功完成执行某些操作-这就是为什么您倾向于将其链接为do_something && do_something_else_that_depended_on_something的原因.

&& lets you do something based on whether the previous command completed successfully - that's why you tend to see it chained as do_something && do_something_else_that_depended_on_something.

这篇关于“&&"的目的是什么?在一个shell命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆