#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    0
    Rep Power
    0

    Question ksh shell problem.


    Hello all

    If I want to check whether the input is numeric (without contain any characters). which syntax will be used ( grep, fgrep or other..).

    Because I am a unix novice. Could any one give me some example.
    Cheer!
    Last edited by kc1979; August 6th, 2003 at 11:16 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    "grep" expects a file as second parameter. (see "man grep")
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Colorado
    Posts
    21
    Rep Power
    0
    read input
    echo $input | grep .......
    or
    wanted=`echo $input | grep -c.....`

    echo $wanted
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    under a rock
    Posts
    54
    Rep Power
    11

    grep problems


    I like the korn shell too.

    I'd figure out what results you expect from

    grep -c '^[a-zA-Z]$' "$mins"

    ...and then assign that to a variable, and THEN compare it in your if statement. One thing that helps me greatly when I'm having a problem is simplifying down to one step at a time (heh... not just shell scripting either).

    Also, put a line at the beginning of a troubled section like this:

    set -x

    ...and at the end of that section,

    set +x

    they enable and disable debugging feedback, another very useful thing to have in your toolbox.

    Cheers!
    -zedmelon
    Mother says my .sig can beat up your .sig.

IMN logo majestic logo threadwatch logo seochat tools logo