小编Lin*_*Lin的帖子

什么$?在shell脚本中$ 0 $ 1 $ 2是什么意思?

我经常遇到$? $0 $1 $2 etc....shell脚本,我知道的是$?返回最后一个命令的退出状态

echo "this will return 0"
echo $?
Run Code Online (Sandbox Code Playgroud)

但其他人做了什么?他们叫什么,还有更多吗?也许就像$ 3 $ 4 $ 5 ...

bash shell ash

71
推荐指数
2
解决办法
23万
查看次数

如何在bash case命令中执行“else”?

filter="yes"
phonenumbers=(123 456 789 987 654 321)
echo "checking inbox now..."
myphonenumber=(7892)

if [[ "$filter" == "yes" ]]; then
    case "${phonenumbers[@]}" in
        *"$myphonenumber"*) echo "filter is on, phone number matches" 
        ;;
        !="$myphonenumber") echo "filter is on but the phone number doesn't match" 
        ;;
    esac
fi

if [[ "$filter" == "no" ]]; then
    echo "filter off"
fi
Run Code Online (Sandbox Code Playgroud)

我尝试运行该脚本但它不起作用,我应该如何显示该filter is on but the phone number doesn't match部分?我还在学习,我知道我可以用if else语句来做到这一点,但我想知道我是否也可以做到case

bash

6
推荐指数
1
解决办法
4224
查看次数

什么是重置 USB 蜂窝调制解调器的 AT 命令?

用于重置 USB 蜂窝调制解调器的 AT 命令序列是什么?

是否有可以使用的单个 AT 命令?或者它是否需要多个序列才能重置 USB 蜂窝调制解调器?

我有华为 E272 和 E220,但是如果有任何标准 AT 命令,我也对通用命令序列感兴趣。

command at-command

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

如何在灰中使用阵列?

出于某种原因,我无法使用bash构建我的脚本,唯一的方法是使用ash,我有这个短信自动响应脚本,每个回复必须最多160个字符长,它看起来像这样:

#!/bin/sh
    reply="this is a reply message that contains so many words so I have to split it to some parts"
    array="${reply:0:5} ${reply:5:5} ${reply:10:5} ${reply:15:5} ${reply:20:5}"
    for i in $array
    do
    echo "send sms with the message: $i"
    done
Run Code Online (Sandbox Code Playgroud)

但它最终会像这样:

send sms with the message: this
send sms with the message: is
send sms with the message: a
send sms with the message: reply
send sms with the message: mess
send sms with the message: age …
Run Code Online (Sandbox Code Playgroud)

ash

5
推荐指数
1
解决办法
6590
查看次数

PHP:如果文件不存在则退出脚本

<?php
$filename = '/path/to/foo.txt';

if (file_exists($filename)) {
    echo "The file $filename exists";
}
?>
Run Code Online (Sandbox Code Playgroud)

该脚本仅检查文件是否存在,但我该如何做这样的事情?

<?php
$filename = '/path/to/foo.txt';

if (file doesnt exist) {
    exit("Your file doesn't exist");
}
?>
Run Code Online (Sandbox Code Playgroud)

php

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

ash ×2

bash ×2

at-command ×1

command ×1

php ×1

shell ×1