I want to create a script that asks the user for his username and check if its valid by verifying the user home directory exists. If the username exists it should send an email to the user from a predefined .txt file. If the user does not exist it should persist until a valid username is given. Also if the word "exit" is submitted as username the script should exit. This is what i have done so far:
#!/bin/bash echo "Input your username" dir="/home" read username if [$username -e $dir] then cat Message.txt | mailx -s "Subject" $username else echo "The user does not exist. Please type a valid username." fi
I think the part with the message is fine(not sure though) but i have problems with the exit and the input validation!