使用Shell脚本比较用户帐户 [英] Compare user account using shell script
本文介绍了使用Shell脚本比较用户帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所有访客
我想编写一个有关用户帐户的shell脚本
如何比较系统中的用户帐户和我在Shell脚本中输入的用户?
谢谢
hi all visitors
i want to write one shell script about user account
how can i compare user account in system and the user that i inputted in shell script?
Thanks
推荐答案
使用id
[ ^ ]命令,丢弃任何输出,仅检查退出状态.如果用户名已经存在于用户数据库中,则状态为0;如果不存在,则状态为1.
例如,假设要测试的名称在变量中
Use theid
[^] command, discard any output and check only the exit status. The status is 0 if the username already exists in the user database, 1 if it doesn''t exist.
For example, assuming the name to be tested is in the variable
NEWUSER
NEWUSER
id
NEWUSER&> /dev/空 如果[
NEWUSER &> /dev/null if [
这篇关于使用Shell脚本比较用户帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文