Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
Languages and Scripting
Showing results for 
Search instead for 
Did you mean: 

convert script to ksh93 (version 93 )

Go to solution
Valued Contributor

convert script to ksh93 (version 93 )



i want to convert a script to ksh93 ( korn shell version 93 ) .




i want to replace following warning(s) like :


warning: line 1: `...` obsolete, use $(...)

following options i find in scripts, but some option's aren't possible to handle (for me)
like "var6" variante 6  in attachment. also "var4" is not ok. 


has anybody an idea ?

here are some options, what can be listed in a script KSH88

1. replace :  =`
    by          :  =$(

2. replace :  `$
    by          :  )

3. replace :  `character
    by           :  $(

4. replace :   character`
   by             : character )

5. replace :  ?`
    by          :  ? )

6. replace :  "`
     by         :  " )

7. replace :  }`
     by        :  } )


here is my "sed" converter :


sed -e "s|=\`|=$\(|g" \
    -e "s|\`$|\)|g" \
    -e "s|\`\([a-z]\)|\$( \1|g" \
    -e "s|\([a-z\?\"\?]\)\`|\1 \)|g" ${file}  > ${file}.ksh93

ksh -n ${file}.ksh93


testing : sed of attachment and test syntax of new file with version 93 : ksh -n


kind regards

Steven Schweda
Honored Contributor

Re: convert script to ksh93 (version 93 )

Dennis Handly
Acclaimed Contributor

Re: convert script to ksh93 (version 93)

>warning: line 1: `...` obsolete, use $(...)


You should have done this as soon as you abandoned the Bourne and scummy C shell decades ago.

I started doing that as soon as I read "archaic" under Command Substitution.

(I  typically did it manually.)


sed -e "s|=\`|=$\(|g" \
    -e "s|\`$|\)|g" \
    -e "s|\`\([a-z]\)|\$( \1|g" \
    -e "s|\([a-z\?\"\?]\)\`|\1 \)|g" ${file}  > ${file}.ksh93


You can do this a little easier without all that quoting if you put it in single quotes:

sed -e 's|=`|=$(|g'   -e 's|`$|)|g'  -e 's|`\([a-z]\)|$( \1|g'  -e 's|\([a-z?"]\)`|\1 )|g'


(You don't need to quote the "?", nor have two of them.)

Valued Contributor

Re: convert script to ksh93 (version 93)



thx to your answers.


@ Steven



sed -e 's/`\([^`]*\)`/$(\1)/g'


this handle 90 % of my script(s).


That won't help if the two "`" characters are on different lines, as in:

     if [ `echo "var6" |grep "var6"  > /dev/null 2> /dev/null; \
            echo $?` -eq 0 ]


with the other "sed" options i can handle it ?  like :


sed -e 's/`\([^`]*\)`/$(\1)/g' -e 's|\([?]\)`|\1)|g'  -e 's| `\([a-z]\)| $(\1|g' -e 's|=`|=$(|g' -e 's|`$|)|g'


@ Dennis


in some scripts are statements  ( here it is a example of a "case" statement  ) like

var7=` echo "a b c" | \
       awk ' { print $1 } '`  ;;



so i want to "devaluate" the of sed

sed -e 's|\([?']\)`|\1)|g'


like :

sed -e 's|\([?\']\)`|\1)|g'




but i can't  devaluate in a class



Dennis Handly
Acclaimed Contributor

Re: convert script to ksh93 (version 93)

>I want to "devaluate" the ' of sed


(This is called quoting in a shell.)

>sed -e 's|\([?']\)`|\1)|g'

You can stutter quotes: 'don'\''t'  (that's two single quotes, not double quote.
sed -e 's|\([?'\'']\)`|\1)|g'

Valued Contributor

Re: convert script to ksh93 (version 93)

@ Dennis : Thank you for your correction, now it works.


@ Dennis , Steven : With your input's i have a final solution :


sed -e 's/`\([^`]*\)`/$(\1)/g' -e 's|\([?'\''"]\)`|\1)|g' -e 's| `\([a-z]\)| $(\1|g' -e 's|=`|=$(|g' -e 's|`$|)|g'


this handle 95 % of ksh 88 script(s). the rest you have to correct manually.