i get a name from user first name : last name, in this format. Now i am saving this to a file. what i want is, I do not want to save any name if I already have one entry o that same name..what should i do
for example
user give robert fernandez
this will save in file as robert:fernandez.
if user give same name in future i dont want tht to be saved in the file, instead it should give message that this name is already there.
newname="robert:fernandez"
grep -q "$newname" listfile
if [[ $? -eq 0 ]; then
echo "not okay"
# insert code to handle an existing entry
else
echo "ok"
# code to handle new name
fi