慕粉4265099
2022-09-12
这个选项用于从标准输入管道读入新的密码。
使用 echo 方式来重置Linux 系统用户密码:
echo “新密码”|passwd --stdin 用户名
慕尼黑1472646
2020-11-17
慕标8171997
2020-05-18
慕粉3471523
2020-04-05
慕粉3471523
2020-04-04
慕移动1325614
2020-03-24
慕移动1325614
2020-03-24
支持,可以使用$(())进行运算
慕设计8017497
2019-12-24
```sh
# ✅
[ ./student.sh -ef ./soft ] && [ -L ./soft ] && echo yes || echo no
[ ./student.sh -ef ./hard ] && [ -L ./hard ] && echo yes || echo no
```

慕先生7046963
2019-12-15
_执着_
2019-12-10
_执着_
2019-12-10
xshell 连接的服务器,服务器是centos的
测试妞李西西
2019-11-19
首先你要确定df -h输出的根分区是否为/dev/sda3,然后第二行最后的-f1是有空格的,应该为-f 1才对,不知道对你有没有帮助
慕哥2296688
2019-09-11
查了一下, = 和==的作用一样,只要=左右有空格即可。自己试了一下也确实是这样
0_菇凉将我作甚_0
2019-09-05
好吧,我知错了 ==两边也要用空格
慕粉1056356323
2019-08-24
第9行的if没有对应的fi。
慕粉1056356323
2019-08-23
#!/bin/bash
read -p "number1: " num1
read -p "number2: " num2
read -p "ope: " ope
if [ -n "$num1" -a -n "$num2" -a -n "$ope" ]
then
test1=$(echo $num1 |sed 's/[0-9]//g')
test2=$(echo $num2 |sed 's/[0-9]//g')
else
echo "enter number is null,try again"
exit 12
fi
if [ -z "$test1" -a -z "$test2" ]
then
echo "Please enter a valid value"
exit 10
fi
if [ "$ope"=='+' ]
then
sum=$(( $num1 + $num2 ))
elif [ "$ope"=='-' ]
then
sum=$(( $num1 - $num2 ))
elif [ "$ope"=='*' ]
then
sum=$(( $num1 * $num2 ))
elif [ "$ope"=='/' ]
then
sum=$(( $num1 / $num2 ))
else
echo "Please enter a valid symbol"
exit 11
fi
echo "$num1 $ope $num2 = $sum"
慕田峪3367142
2019-08-19
个人认为:read命令后面的变量,属于赋值,所以不需要$()。其它的调用变量的命令,需要$()。
醉李白
2019-08-16
too many arguments的意思是:参数太多。line6表示:第六行。仔细看看你的脚本第六行,是不是有多余的符号把你的参数隔开了,使得参数看起来太多了。
qq_慕斯2366313
2019-07-29
这样看代码看不到你说的问题,你应该把报错也贴上的。
暂时看见有几个问题:
-n 与“num1” 中间要有空格。
== 两边要有空格
[ xxx ] 方括号里的判断要跟两个方括号之间有空格
除法那行不要带双引号
最后一行只要在两边加双引号就够了,不要写那么多双引号
可能还有漏看的。。。
下面是我写的拆解过if结构的
#!/bin/bash # 例子:计算器 read -t 30 -p "input num1:" num1 read -t 30 -p "input num2:" num2 read -t 30 -p "input ope(+-*/):" ope if [ -n "$num1" -a -n "$num2" -a -n "$ope" ] then test1=$(echo $num1 | sed 's/[0-9]//g') test2=$(echo $num2 | sed 's/[0-9]//g') if [ -z "$test1" -a -z "$test2" ] then echo "check ok " else echo "error input" exit 10 fi else echo "num1,num2,ope must be not null" exit 11 fi # 开始计算 if [ "$ope" == "+" ] then res=$(($num1+$num2)) elif [ "$ope" == "-" ] then res=$(($num1-$num2)) elif [ "$ope" == "*" ] then res=$(($num1*$num2)) elif [ "$ope" == "/" ] then res=$(($num1/$num2)) else echo "ope error" fi echo "res:$res"
慕桂英8296600
2019-07-17
赋值时不用加,调用时需要加
绛心
2019-07-02
sum = $(($num1+$num2)),=前后不能有空格吧,得是sum=$(($num1+$num2))
公鸡喔喔喔
2019-05-28
user 包含匹配 输出两个结果;要想输出一个 用界定符 "\bUSER\b"
阿强0519
2019-05-25
if ["$ope"=="+"];then 这里的应该这样 if [ "$ope" == "+" ] ;then
明白了吗,2个等号旁边要有空格,2个中括号跟双引号的内容之间也要有空格,目前发现这个问题
Stone_He
2019-05-22
后面缺个空格
奔跑的菜鸟_
2019-05-05
变量num是你要创建的用户个数,在for循环中,需要调用变量i来控制执行次数,你调用了变量num
慕九州1224321
2019-04-25
赶紧登陆root账号再新建回来
weixin_慕神0383422
2019-04-20
呃&aa和&bb没有讲过呢,$aa应该就对了吧
weixin_慕神0383422
2019-04-20
看下符号“&”,获取变量值要用“$”
weixin_慕标0518098
2019-02-11
这样也可以。你也可以这样 check=$(netstat -an | grep :80)就可以了。
weixin_慕标0518098
2019-02-11
一个一个判断没必要把if都套起来吧,可以拆开来写,一层层的if强迫症看着难受。