linux 中 && 用法

发布时间 2023-09-21 11:10:43作者: 小鲨鱼2018

 

001、

[root@pc1 test2]# ls
test.sh
[root@pc1 test2]# cat test.sh
#!/bin/bash

seq 10 > a.txt

xxxxxx  && echo 20 done ; rm a.txt
[root@pc1 test2]# bash test.sh
test.sh: line 5: xxxxxx: command not found
[root@pc1 test2]# ls
test.sh

 

002、修改程序

[root@pc1 test2]# ls
test.sh
[root@pc1 test2]# cat test.sh
#!/bin/bash

seq 10 > a.txt

xxxxxx  && echo 20 done && rm a.txt
[root@pc1 test2]# bash test.sh
test.sh: line 5: xxxxxx: command not found
[root@pc1 test2]# ls
a.txt  test.sh