On Friday 25 March 2011 05:56 PM, Binand Sethumadhavan wrote:
2011/3/25 Rony Billgnulinuxist@gmail.com:
if grep -q "$USER" present then echo "Sorry! You have already logged in today."
I have several comments on style and other issues, but this snippet is plain buggy. Imagine two users, prabhakaran and karan. If the former has marked his attendance, this code will not allow the latter to do so at all.
I created a test script like the above
#!/bin/bash
echo -n "Please enter your name: " read -e USER if grep -q "$USER" namelist then echo $USER else echo "Name does not exist" fi
In namelist file I added Rony, Macrony and karan.
While both rony and Rony are accepted, for the other 2 names they are even case sensitive and do not accept macrony or Karan. Even prabhakaran and karunakaran are rejected. Why rony is not case sensitive is still a mystery.