Hi,
Can someone tell me if these answeres are correct?
1) a system administrator maintains a file with birthdates of all users in /etc/birthdates. The file contains a line for each user, and is updated with the addition of every new user. Each line /etc/birthdates has the following format:
login name: real name: birthdate
#!/bin/sh
DATE=`date '+%d-%m-%y'`
USERS=`grep $DATE /etc/bithdates awk -v FS=":" '{ print $1 }'
for USER in $USERS
do
echo "Happy birthday !" | mail $USER
done
2)1. How to write a bash script that
a. runs automatically every time you log in.
user need to include scripts directly into .bashrc so they could run each time user's shell login
b. tells you when you last logged in.
ans1) lastlog | grep $USER
ans 2) last | grep $USER | head -n 2 | tail -n 1 | awk {'print $3" "$4" "$5" "$6'}
which one is correct?
c. tells you the number of times you have logged in before now.
last | grep $USER | wc -l
Please let me know if these are correct?.
Thanks.