Bash script
hi people,
can you tell me if these ans. are correct?
thanks
1. How to write a shell script to look into this file and send a birthday-congratulation e-mail to relevant users at 1:00 a.m. every day. Make your script as short as possible.
#!/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
2)How to write a bash script that takes the name of a directory as an argument and searches the file hierarchy rooted at that directory for zero length files. Write the names of all zero length files to standard output. If there is no option on the command line, have the script delete the file after displaying its name. An -i option on the command line indicates that the script should ask the user for confirmation before deleting the file.
ans:
$ cat zerdel
if [ $1 == -i ]
then
find $2 -empty -print -exec rm -i {} \;
else
find $1 -empty -ok rm -i {} \;
fi
|