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

    Join Date
    Aug 2012
    Posts
    1
    Rep Power
    0

    Unix


    This is a weird question, But has anybody come across a command 'found' in UNIX ??

    The context is

    If ( grep something something)
    found something in something
    echo "something"

    fi
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,406
    Rep Power
    1871
    Perhaps something like
    Code:
    grep -q -s "something" file
    if [ $? -eq 0 ]; then
      echo found it
    fi
    All commands return an exit status you can test in the shell using $?

    The precise syntax of the if statement varies a bit from shell to shell, but most use $? to indicate the exit status of the previous command.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo