Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    3

    Unanswered: using if/else with utility

    I'm a newbie in programming shell scripts. I want to write a script for the following but I don't know how, anyone knows please help. thanks

    if (success find a file "A" in the current directory)
    echo "found it"

    else (do something else)

    I tried to use the find utility but got an error like if: Expression syntax

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Code:
    if [ -f ./A ] ; then
      echo "found it"
    else
      dosomethingelse
    fi
    The "[" is an alias for the programme called "test". For more details run "man test".

  3. #3
    Join Date
    Oct 2005
    Posts
    3
    Quote Originally Posted by n_i
    Code:
    if [ -f ./A ] ; then
      echo "found it"
    else
      dosomethingelse
    fi
    The "[" is an alias for the programme called "test". For more details run "man test".
    Thanks for quick reply, but when I run it I have something like this

    Code:
    Missing ]

  4. #4
    Join Date
    Oct 2005
    Posts
    3
    never mind, i think i got it, thanks

Posting Permissions

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