If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > expr on SunOS

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-04-03, 04:17
dove17 dove17 is offline
Registered User
 
Join Date: Apr 2003
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 04-24-03, 03:23
halkan halkan is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On