Link to home
Start Free TrialLog in
Avatar of r__b
r__b

asked on

porting script from AIX 4.2 ksh to Linux ksh/bash

Interresting one. I am experimenting with scripts on unix. I wrote a basic script to check if the first command line parameter starts with gr.

--------------
firstparm=$1
firstparm=${firstparm:?"missing"}
if [[ $firstparm = gr* ]] ; then
  echo The parameter starts with gr
else
  echo The parameter does NOT starts with gr
fi
--------------

On AIX this works fine, but when I try to run this in Linux Redhat 6.0 bash (v 1.14.7) or ksh (PD v5.2.14) I get the error:
[[: command not found.

Why?
Any references will be welcome.
Avatar of ahoffmann
ahoffmann
Flag of Germany image

this is a know bug in pdksh version < 5.2.4
see http://www.cs.mun.ca/~michael/pdksh/
Avatar of r__b
r__b

ASKER

Fair, but what about bash. I have to admit that I am not an expert in bash scripting and is not sure if it should be working.

In both cases, what would work?
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of r__b

ASKER

Thanks A Hoffmann (I assume)

Guess it is back to the man pages for me. I know it will not work, but I am not experienced enough to know what would work.

muru_za
> but I am not experienced enough  to know what would work.
man sh