So I am hoping this is a very simple fix. I am still learning how to write some scripts but I have a file with a list of names such as:
sname.txt
Joey
Kaylin
Dad
Mom
Melissa
Toby
I am trying to have the script check the value of it's $fname against the names in the file, if it is in there then it will store print the fname as the users first name if not then it will append the sname.txt file with that name and again print the first name.
here is what i got. Please don't berate me for how jacked up it may be.
#Displaying user first name storing to snames.txt
echo "Your first name please:"
read fname
for fname in snames.txt
do
if [ $fname = `| grep $fname sname.txt` ] ; then
fname=stored_fname
elif [ $fname != `| grep $fname sname.txt` ] ; then
fname >> sname.txt ; then
fname=stored_fname
#Displaying user last name storing to snames.txt
echo "Your Last name please:"
read lname
#for lname in snames.txt
#do
# if [ $lname = | grep $lname sname.txt ] ; then
# lname=stored_lname
# elif [ $lname != | grep $lname sname.txt ] ; then
# lname >> sname.txt ; then
# lname=stored_lname
echo "Hello $stored_fname $lname, Lets be Friends!"
___________________________________________
I decided to comment out the last name portion of it till i can get the first name portion. Any help would be appriciated. Thanks