相关疑难解决方法(0)

什么是"$?" 准确地给我们一个shell脚本?

我看到代码写在网上的某个地方,我想知道究竟什么是"$?" 做/给我们.谷歌搜索没有帮助.

这是我看到的代码:

#!/bin/sh

ping -c 2 localhost
if [ $? != 0 ] ; then
    echo "Couldn't ping localhost, weird"
    fi

ping -c 2 veryweirdhostname.noend 
if [ $? != 0 ] ; then
    echo "Surprise, Couldn't ping a very weird hostname.."
    fi

echo "The pid of this process is $$"
Run Code Online (Sandbox Code Playgroud)

取自:http://efod.se/writings/linuxbook/html/shell-scripts.html

linux bash shell sh

26
推荐指数
3
解决办法
5万
查看次数

标签 统计

bash ×1

linux ×1

sh ×1

shell ×1