Results 1 to 2 of 2

Thread: Bash script

  1. #1

    Bash script

    Hi,
    I am learning linux. Doing some book exercise ques.

    Can someone tell me if these answers are correct.?

    Thanks

    1) write a bash script that, 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. 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

    done




  2. #2

    Re:Bash script

    Heh. This sounds supiciously like homework!

    I can't help you because I've never done any scripting. However, you can look at the following links:

    A quick guide to writing scripts using the bash shell

    Bash Scripting Introduction HowTo

    Advanced Bash-Scripting Guide

Similar Threads

  1. Help with bash script
    By woodson2 in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 12-30-2010, 07:19 PM
  2. SSH and bash script
    By vwgtiturbo in forum Programming
    Replies: 7
    Last Post: 12-25-2008, 05:40 AM
  3. Bash script problem
    By Schotty in forum Programming
    Replies: 1
    Last Post: 04-20-2007, 01:18 AM
  4. Help with bash script
    By tolstoy in forum Programming
    Replies: 5
    Last Post: 05-21-2002, 11:17 AM
  5. Bash script for sorting mp3's.
    By airhead in forum Programming
    Replies: 7
    Last Post: 02-24-2002, 07:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •