linux判斷用戶是否存在的方法:1、將“read -p “please input a username:” username…”保存為test.sh;2、運行“sh test.sh”即可。
本文操作環境:linux5.9.8系統,Dell G3電腦。
linux怎么判斷用戶是否存在?
linux 判斷一個用戶是否存在:
#!/bin/bash read?-p?"please?input?a?username:"?username if?id?-u?$username?>/dev/null?2>&1;?then ????????echo?"user?exists" else ????????echo?"user?does?not?exist" fi
把上面內存保存為 test.sh , 然后 sh test.sh 運行
推薦學習:《linux視頻教程》
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦