Find the answer to your Linux question:
Results 1 to 2 of 2
I create a bash script with using case syntax. My bash script option must be " ./script user hello ". Below is the content of the script. user=`echo "$1" | ...
  1. #1
    Linux Newbie
    Join Date
    Mar 2006
    Posts
    101

    help me in my bash script

    I create a bash script with using case syntax. My bash script option must be "./script user hello". Below is the content of the script.


    user=`echo "$1" | sed "s/$/@foo.com/"`

    case $1 in
    *)
    echo "From: $user
    TEST1" > /var/log/test1

    echo -n " TEST2" > /var/log/test2

    ;;

    esac
    I want to modify it and do something like this.

    If I run the script ./script user (without the word "hello"), it will echo -n " TEST2" > /var/log/test2, if I run the script ./script user hello, it will return echo -n " TEST1". I'm thinking if I can do this using if syntax though I'm not sure and still checking if can do this.

    Ant advise?

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,695
    Google: bash scripting

    Bash Scripting Guide

    Chapter 7 - Tests

Posting Permissions

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