So I've got these two files, see. One is a list of usernames I gathered from:
ls -AlHr --sort=time /var/mail > users
I cleaned up my "users" file (from the command above) and now it contains only usernames of people who haven't checked their emails in forever.
The other file is /etc/features, which has a list of all usernames and a "description" field containing the user's real name. It is formatted like so:
doug:mail=10,ftp=0,description=CD - Doug Adams
I want to compare those two files and pick out only the lines containing names which appear in "users." For example, photo1 may be the only name which appears in both places. Here's the script I wrote to do that:
for i in `cat ~/users`;
do grep $i /etc/features;
When I run this, it sets the environment variable correctly, but it never matches the data. If I pass "echo $i" it contains the value found last in "users."
Now, here's the weird part. I wanted to see if it was searching literally for "$i" so I passed:
echo "$i testing..." >> /etc/features
And when I ran my script again, it displayed:
How is grep matching the data and how do I write it properly to do what I need?
Thanks in advance!