首页 > 其他 > 详细

shell-用grep查看输入的参数是否在/etc/passwd中

时间:2014-04-18 17:10:05      阅读:622      评论:0      收藏:0      [点我收藏+]

编写脚本:

#!/bin/bash

#####用grep查看输入的参数是否在/etc/passwd中

#####在,则输出keywords exits,否则输出didn‘t find keywords

#####次参数既可以为字母。也可以为字符串、数字

echo "please input the keywords: "

read -r x

if grep $x /etc/passwd > /dev/null

then

echo "The keywords $x exits!"  

else

echo "didn‘t find $x"

fi

给脚本passwd加可运行权限

chmod +x passwde

运行脚本:./ passwd


注:除了在/etc/passwd中查看,读者还可以根据自己的需要,更改文件


shell-用grep查看输入的参数是否在/etc/passwd中,布布扣,bubuko.com

shell-用grep查看输入的参数是否在/etc/passwd中

原文:http://cuanlf.blog.51cto.com/8241982/1397689

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!