![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script $0 argument | painulyarun | UNIX for Dummies Questions & Answers | 2 | 03-25-2008 07:32 PM |
| Problem with Argument Passing | A_Rod | Shell Programming and Scripting | 4 | 09-13-2006 11:47 AM |
| Passing argument from one script to other | lloydnwo | Shell Programming and Scripting | 3 | 10-27-2005 02:06 PM |
| shell script argument parsing | rmjoe | Shell Programming and Scripting | 1 | 07-28-2005 03:37 PM |
| Passing argument to awk script | AkumaTay | UNIX for Dummies Questions & Answers | 1 | 08-03-2001 11:12 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Problem when passing argument to a shell script
Hi all,
I'm new to Shell scripting. In my shell script for Bourne shell, the script accepts a date parameter which is optional. If the value is supplied, the supplied value should be assigned to a variable. If not, the current date will be assigned to the variable. My script is like this. Code:
#! /bin/sh if [ ! -z $1 ] then dateval=`date` elif [ $dateval -gt date ];then echo "Supplied date is greater than current date" else dateval=$1 fi echo $dateval ./shellpgm30.sh: test: argument expected Any help would be appreciated. Thanks, Sumesh |
|
||||
|
Anbu,
Thanks for the reply. I'm using sh. The sample code is given below. Code:
#! /bin/sh if [[ -z $1 ]] then echo "Does not contain any value" else echo "Contains value" fi Code:
./shellpgm32.sh Code:
./shellpgm32.sh: [[: not found Thanks, Sumesh |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|