아래 코드를 실행하면 "19행: checkUser: 명령을 찾을 수 없습니다"라는 오류 메시지가 나타납니다.
나는 사용해 보았습니다.주택 검사하지만 여전히 코드로는 문제를 해결할 수 없습니다.
#!/usr/bin/env bash
checkUser() {
while true; do
read -p "Enter username you would like to generate: " userName
if id "$userName" >/dev/null 2&>1; then
echo "Sorry user exists"
else
read -s -p "Enter password : " userPass
echo adduser "$userName"
printf "User %s has been added\n" "$userName"
read -p "Enter group you want to assign user to: " userGroups
useradd -G "userGroups" "$userName" &&
printf "User has been added to group %s\n" "$userGroups"
fi
read -p "Do you want to add another user? [y/n] " yn
if [[ $yn = *[nN]* ]]; then
break
fi
done
}
checkUser