I am trying to code an if statement that accepts two parameters and see if those parameters are in another file called teledir.txt. If it already exists in the file, it is to say "Entry Exists". If not, I add it to the file and say "Entry Added". This is the code I have so far:
if [ $# -eq 2 ]; then
if grep "$1:$2" teledir.txt; then
echo "Entry exists"
else
echo "$1:$2" >> teledir.txt
echo "Entry Added"
fi
fi
When I run this, if I enter a name and number that is in the file, it says entry added and places it into the file. I'm new to the command line but what am I missing?