Results 1 to 2 of 2

Thread: expr on SunOS

  1. #1
    Join Date
    Apr 2003
    Posts
    1

    Unanswered: expr on SunOS

    Hi,
    I have this peice of code that does not work on SunOS. Can anyone tell why?

    #! /bin/sh
    showdate=05042003

    echo $showdate
    aday="`expr ${showdate:0:2}`"
    echo "day is $aday"
    exit 0


    if i do it from command line like
    bash$ >showdate=05042003
    bash$ >aday="`expr ${showdate:0:2}`"
    bash$ >echo $aday
    05

    i get correct answer but it does not work in script.

    all answers are welcome.

    dove17

  2. #2
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    1
    In your command line example, you are using the "bash" shell. However, in your script you are forcing the script to use "sh" shell by including #!/bin/sh.
    Change it to #!/bin/bash (or wherever bash shell is installed on your system) and you should see identical results.

Posting Permissions

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