#!/bin/bash echo "hands-onユーザを削除しますか? (yes/no)" read response if [ "$response" != "yes" ]; then exit 0 fi FILE_U="users.txt" FILE_P="/etc/passwd" newusers $FILE_U for line in `cat $FILE_U` do user_name=`echo $line | cut -d ':' -f 1` txt=`cat $FILE_P | grep -e "^$user_name"` user_id=`echo $txt | cut -d ':' -f 3` group_id=`echo $txt | cut -d ':' -f 4` home_dir=`echo $txt | cut -d ':' -f 6` userdel -r $user_name done