Você terá que elaborar mais em sua pergunta se estiver procurando mais. Isso deve começar você.
#!/bin/bash
file=database.dat
echo "Enter a username:"
read username
grep -i "$username" "$file"
if [ $? == 0 ] ; then echo "User already exists"
exit 1
else
echo "$username" >> "$file"
fi
Aqui está a saída ...
ubuntu@ubuntu-xenial:~/t2$ ./test.sh
Enter a username:
myname
ubuntu@ubuntu-xenial:~/t2$ ./test.sh
Enter a username:
myname
myname
User already exists
ubuntu@ubuntu-xenial:~/t2$