#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2006
    Posts
    3
    Rep Power
    0

    Question 2 Linux shell script (Bash) problems


    Hi,

    I'm only a shell script beginner but unfortunately I have to write some cron job in Bash shell. I get 2 problems right now.

    1.) I need to read a config file like this

    sample.conf
    ======================
    key1=value1
    key2=value2

    how can I create variable so that
    $key1 = value1 and $key2 = value2 ??

    now I have

    cat sample.conf | while read NAME VAL
    do
    export NAME=VAL
    done

    but "export" doesn't work (this script works in ksh).

    2.) "Date" function gives me today, but how can I get yesterday? And in general is there any function that allows me to manipulate date?

    Thanks for your help in advance.

    Michael
  2. #2
  3. fork while true;
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2005
    Location
    England, UK
    Posts
    5,538
    Rep Power
    1051
    export just sets the environment variable.

    What I'd do is use sed to parse them off, but I'm no sed expert so you're on your own.

IMN logo majestic logo threadwatch logo seochat tools logo