Results 1 to 4 of 4

Thread: Bash script if then else help

  1. #1
    Join Date
    Jul 2009
    Posts
    58

    Bash script if then else help

    I'm new to bash script programming and i need to make some of my own loop programs. Can anyone help me with it? Bash script if then else help, this is what i need, can anyone help with some examples...

  2. #2
    Join Date
    Jan 2009
    Posts
    1,738

    Re: Bash script if then else help

    The syntax for If Then Else is as follows :

    Code:
    if [condition]
    then
    <task-command-or-jump>
    else
    <task-command-or-jump>
    fi
    You can try and implement it in your program. See what you get...

  3. #3
    Join Date
    Jul 2009
    Posts
    58

    Re: Bash script if then else help

    Ok, thanks for the syntax but it will take me some time to get it into my head, can you give an example? Thanks! But i will need it to understand... Please help...

  4. #4
    Join Date
    Jan 2009
    Posts
    1,738

    Re: Bash script if then else help

    Try to understand this example :

    Give a value to a variable 'a' which is less then 1

    Code:
    if [a>1]
    then
    print "a is greater then 1"
    else
    print "a is less then 1"
    fi
    Give a value to a variable 'a' which is greater then 1

    Code:
    if [a>1]
    then
    print "a is greater then 1"
    else
    print "a is less then 1"
    fi
    See the result variation and then you try to use it in your programs, it will help you...

Similar Threads

  1. Bash script needs to e-mail output
    By Kim|ball in forum Technology & Internet
    Replies: 4
    Last Post: 27-05-2011, 10:19 AM
  2. How to create CGI script in bash?
    By Mulan in forum Software Development
    Replies: 5
    Last Post: 01-09-2010, 08:19 PM
  3. Linux bash script with the command w
    By Trini Alvarado in forum Operating Systems
    Replies: 4
    Last Post: 22-03-2010, 12:11 PM
  4. Create bash script for ftp
    By teenQ in forum Operating Systems
    Replies: 4
    Last Post: 04-03-2010, 07:37 PM
  5. Bash Script, read without new line
    By Kieran in forum Software Development
    Replies: 2
    Last Post: 06-02-2009, 09:59 PM

Tags for this Thread

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
  •  
Page generated in 1,711,706,349.58165 seconds with 16 queries