【问题标题】:What does #!/bin/bash set -o pipefail if [[ $# -ne 1 ]] if [ $? -eq 0 ] mean in shell scripting [duplicate]#!/bin/bash set -o pipefail if [[ $# -ne 1 ]] if [ $? -eq 0 ] 在 shell 脚本中的意思 [重复]
【发布时间】:2020-08-11 10:53:06
【问题描述】:

我正在浏览一个脚本并发现了这个:

#!/bin/bash
set -o pipefail
if [[ $# -ne 1 ]]
if [ $? -eq 0 ]

【问题讨论】:

  • 你知道$#是什么吗? [[ ]] 是什么意思? -ne 里面是什么意思?

标签: bash shell


【解决方案1】:

$# 是位置参数的“数量”

示例:

./script.sh foo bar

这里我们有 2 个位置参数(foo 和 bar)

此代码检查位置参数“count”是否不是 1

【讨论】:

    猜你喜欢
    • 2016-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-22
    • 1970-01-01
    • 2017-08-15
    相关资源
    最近更新 更多