Need assistance to resolve the KSH issue

am running the small script below.

count_a=48
count_b=48
if [$count_a -eq $count_b]; then
echo "Count matched"
else
echo "count not matched"
fi

I got the below output.

/bin/ksh: [48: not found
count not matched

It was giving the same error when I ran in another box. But I inculded /bin/ksh in the 1st line. Then It was working fine.
But same way I followed here also. even it is giving error.

And I tried the way also as I added #!/bin/ksh in the 1st line. But not favour.

my /bin/*sh output is given below.

-rwxr-xr-x 1 root other 703 Dec 16 2004 /bin/gnome-autogen.sh
-r-xr-xr-x 17 root bin 134 Jan 21 2005 /bin/hash
-r-xr-xr-x 1 root bin 735572 Jan 23 2005 /bin/bash
-r-------- 1 root bin 27752 Jan 23 2005 /bin/rsh
-r-xr-xr-x 2 root bin 159592 Jan 23 2005 /bin/pfcsh
-r-xr-xr-x 2 root bin 159592 Jan 23 2005 /bin/csh
-r-xr-xr-x 3 root bin 209256 Jan 23 2005 /bin/rksh
-r-xr-xr-x 3 root bin 209256 Jan 23 2005 /bin/pfksh
-r-xr-xr-x 3 root bin 209256 Jan 23 2005 /bin/ksh
-r-xr-xr-x 1 root bin 257288 Jan 23 2005 /bin/ssh
-r-xr-xr-x 1 root bin 363280 Jan 23 2005 /bin/tcsh
lrwxrwxrwx 1 root root 13 Jan 11 2006 /bin/jsh -> ../../sbin/sh
lrwxrwxrwx 1 root root 13 Jan 11 2006 /bin/pfsh -> ../../sbin/sh
lrwxrwxrwx 1 root root 13 Jan 11 2006 /bin/sh -> ../../sbin/sh
lrwxrwxrwx 1 root root 5 Jan 11 2006 /bin/remsh -> ./rsh
lrwxrwxrwx 1 root root 14 Jan 11 2006 /bin/zsh -> ../sfw/bin/zsh
lrwxrwxrwx 1 root other 28 Mar 2 2006 /bin/rpccp.sh -> /opt/OV/dce/bin_exe/rpccp.sh

Pls help me.

It's the old "missing spaces either side of the [ and ]" one

if [ $count_a -eq $count_b ]; then

Not really sure what you're trying to say here:

Add some spaces:

count_a=48
count_b=48
if [ $count_a -eq $count_b ]; then
  echo "Count matched"
else
  echo "count not matched"
fi

Thanks guys.

Yes. the problem was the space . Now it is working fine.

Remember that the "[ ]" is an alias of the "test" command.

Thank you very much.

Can you pls tell me how can I find the current_date+6days date? I mean if I run a script today it should print 22/11/2009.

Important thing is it should work for all the years including leap year.

I need your help for the below activity. (currently it should print the today date)

dat=`date '+%m/%d/20%y'`
partition_date=`date|awk '{print $2$3}'`
new_partition=SAS_AUDIT_$partition_date
echo "The new partition name is "$new_partition""
echo "alter table AUDIT_TRAIL split partition partmax at (to_date('$dat 00:00:00','mm/dd/yyyy hh24:mi:ss')) into (partition
$new_partition,partition partmax);" | sqlplus -s username/pwd

date '+%m/%d/20%y'

returns the current date
try

date now +6 days '+%m/%d/20%y'

Hi.

The date now +6 days doesn't work on my Linux.

As you're using Oracle anyway, why not let it deal with it?

sysdate + 6

will give you the date you're looking for.

There's no hint in your code where you actually intend to use the future date.

Hi,

date now +6 days '+%m/%d/20%y' is not working in solaris.

And I need to do in the shell itself. I cant do in oracle prompt. because the requirement is as such.

So can u pls help me to find the date of currentdate+6 days?

I's working with OpenSolaris (and Solaris if you install gnu date):

$ uname -a 
SunOS pcjll 5.11 snv_118 i86pc i386 i86pc
$ /usr/gnu/bin/date -d "now +6 days" "+%m/%d/%Y"
11/24/2009

I fixed the Y2.1K bug :wink:

If you need something only based on already installed tools, you might use that perl oneliner:

$ perl -MPOSIX -e 'print strftime("%m/%d/%Y%n",localtime(time+6*24*60*60));'
11/24/2009

Thanks for the quick reply.

I think gnu is not installed for me.

$ uname -a
SunOS osp2pits03-th 5.10 Generic_118833-02 sun4u sparc SUNW,Sun-Fire-V440

But perl -MPOSIX -e 'print strftime("%m/%d/%Y%n",localtime(time+6*24*60*60));' is working fine.

shall I use this perl line in a k shell? am new to shell script.that's why am asking.

any my exact requirement as such

inputdate=25/11/2009
requiredate=$inputdate+6
echo "$requiredate"

I tried through the following way.

$ noofdays=$1
$ totaldays=24noofdays
$ next_date=`TZ=CST-$totaldays date +%d/%b/%Y `
$ echo "$next_date"
19/Nov/2009
$ noofdays=$1
$ inputdate=$2
$ totaldays=24
noofdays
$ future_date=`TZ=CST-$totaldays $inputdate `
$ echo $future_date

but $future_date is giving blank output.

pls help to sort out this. or is there anyother simple way than this?