shell初学者写着玩,功能都可以实现,但总会报错:./IFS.sh: line 4: 0: command not found 求大神指点
答案:1 悬赏:0
解决时间 2021-01-23 21:12
- 提问者网友:谁的错
- 2021-01-23 17:58
shell初学者写着玩,功能都可以实现,但总会报错:./IFS.sh: line 4: 0: command not found 求大神指点
最佳答案
- 二级知识专家网友:白昼之月
- 2021-01-23 18:23
帮你检查一下。
1,首先第三行的flag 写成了falg.
2,while 后面是判断,用括号包起来。
3,运行过程中,如果中间有空格会出错。比如ftp,
4,如果使用roo这样的也通过 。
改了下脚本。目前是修复上面的错误。
#!/bin/bash
flag=1
while [ ${flag} ]
do
echo please input your username:
read name
username=`awk -F: '{print $1}' /etc/passwd`
for i in $username
do
if [ X"$i" == X"$name" ];then
hell=`awk -F: '{if($0~/^'"$i"'/) print $7}' /etc/passwd`
echo $i\'s shell is $hell;
exit 0
else
nouser=1
fi
done
[ $nouser=1 ] && echo No such user,please check it and try again!;
done
1,首先第三行的flag 写成了falg.
2,while 后面是判断,用括号包起来。
3,运行过程中,如果中间有空格会出错。比如ftp,
4,如果使用roo这样的也通过 。
改了下脚本。目前是修复上面的错误。
#!/bin/bash
flag=1
while [ ${flag} ]
do
echo please input your username:
read name
username=`awk -F: '{print $1}' /etc/passwd`
for i in $username
do
if [ X"$i" == X"$name" ];then
hell=`awk -F: '{if($0~/^'"$i"'/) print $7}' /etc/passwd`
echo $i\'s shell is $hell;
exit 0
else
nouser=1
fi
done
[ $nouser=1 ] && echo No such user,please check it and try again!;
done
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯