Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I am very new to shell scripting in Linux, i am trying to run the below script but i am getting a syntax error related to 'fi' can anybody ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2011
    Posts
    2

    Shell script giving syntax error


    Hi,

    I am very new to shell scripting in Linux, i am trying to run the below script but i am getting a syntax error related to 'fi' can anybody help me with the problem. Any help is appreciated, Thanks in advance



    :start
    clear
    echo
    echo Deleting Options
    echo -------------------------------------
    echo
    echo '[1] Keep recordings for last 15 days; Delete rest (Today being the First Day)'
    echo '[2] Keep recordings for last 30 days; Delete rest (Today being the First Day)'
    echo '[3] Keep recordings for last 45 days; Delete rest (Today being the First Day)'
    echo '[q] QUIT'
    echo
    echo
    set choice=
    set /p choice=ENTER CHOICE COMMAND:
    if not '%choice%'=='' set choice=%choice:~0,1%
    if '%choice%'=='1' goto 15
    if '%choice%'=='2' goto 30
    if '%choice%'=='3' goto 45
    #if '%choice%'=='q' goto quit
    echo
    goto start

    :15
    find /archive/*.vox .mtime +15 -exec rm {} \;
    #goto start
    fi
    done

    :30
    find /archive/*.vox .mtime +30 -exec rm {} \;
    #goto start
    fi
    done

    :45
    find /archive/*.vox .mtime +45 -exec rm {} \;
    #goto start
    fi
    done

    :quit
    fi
    done

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    err, is this a batch (Windows) script?

  3. #3
    Just Joined!
    Join Date
    Aug 2011
    Posts
    2
    Yes, I tried to apply the same logic, can u help me with the unix version

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Start here for a good tutorial on using Bash.

    In your terminal, do this to see the system documentation for bash:
    Code:
    man bash
    Use the bash scripts in /etc/init.d/ for examples on code usage.

    Basic syntax for a bash script:
    Code:
    func1() {
      echo Function one
    }
    func2(){
      echo Function two
    }
    read -p "Enter a choice: " choice
    if [ "$choice" == '1' ]; then
      func1
    elif [ "$choice" == '2' ]; then
      func2
    fi

Posting Permissions

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