展开全部
#!/bin/bash
username=$1
if [[ $# -eq 0 ]]; then
echo "empty username"
exit 1
fi
uid=$(cat /etc/passwd | grep "^${username}:" | awk -F":" '{print $3}')
if [[ "${uid}" == "" ]]; then
echo "user ${username} not exist"
exit 1
else
echo "uid: ${uid}"
fi
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询