我经常遇到$? $0 $1 $2 etc....shell脚本,我知道的是$?返回最后一个命令的退出状态
echo "this will return 0"
echo $?
Run Code Online (Sandbox Code Playgroud)
但其他人做了什么?他们叫什么,还有更多吗?也许就像$ 3 $ 4 $ 5 ...
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。
用于重置 USB 蜂窝调制解调器的 AT 命令序列是什么?
是否有可以使用的单个 AT 命令?或者它是否需要多个序列才能重置 USB 蜂窝调制解调器?
我有华为 E272 和 E220,但是如果有任何标准 AT 命令,我也对通用命令序列感兴趣。
出于某种原因,我无法使用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) <?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)