How do i check if changes were made to a file using vi

okay, heres the thing

I'm creating a script that I can use to create users. no, this is not a homework assignment or whatever it may seem. i'm just trying to master shell programming.

how can I pass arguments in a file to useradd?????

when i say arguments, I mean, all the arguments and options that is needed to create a user.

I would post my script on here but its just too much to type considering my linux system is installed on a separate hard disk and going back to restart my comp and waiting for it to boot up would be ridiculous

i will post the little bit i remember from the script so if you can help me from the information I supply, please do:

echo -n "Enter user Comment: "
read comment
echo -n "Enter user's home directory: "
read hdirectory
echo -n "Enter user's group: "
read group
echo " "

useradd -c "$comment" -d $hdirectory -g $group

note: (remember, this isn't the whole script)

the question is, how do I save the options and arguments that come after the useradd command in a file and then have the options passed to useradd so useradd can act upon it.

also, how can I have the user go back to the previous prompt when making a user. say, am creating a user using the full version of the script i posted above, how can the user go back to the previous prompt and correct his/her mistake.

to the Admins, Please do not delete or close this thread. THIS IS NOT AN HOMEWORK OR JOB ASSIGNMENT OR ANYTHING THAT GOES AGAINST YOUR POLICY.

THANKS IN ADVANCE

What shell are you using? What OS?

Each time you read a variable, it should be set in that variable
Example (from your script):

echo -n "Enter user Comment: "
read comment

You then use this variable in the useradd command:

useradd -c "$comment" -d $hdirectory -g $group

The $comment should put the information set in the variable comment. If you wanted to put all this into a file (separate it using a character you KNOW will NEVER be in the password file)
then just echo "$user;$comment;$group;$hdirectory" >> myfile

Note the >>. If you use just one > then what ever the last entry is will be the only thing in your file. >> appends to the end of the file.

Post back if I haven't answered all your questions.

And please let me know why you posted a question of how to get information into the comment portion when you had it in your script correctly (using quotes).