Getting pathname variables with ksh

With C Shell you can get the root, head, tail and extension of a pathname by using pathname variable modifiers.

Example Script:

#! /bin/csh
set pathvar=/home/WSJ091305.txt
echo $pathvar:r
echo $pathvar:h
echo $pathvar:t
echo $pathvar:e

The result of executing this script is:

/home/WSJ091305
/home
WSJ091305.txt
txt

My question is: How can this be done using ksh (I specifically need to get the extension)?

Thanks in advance for the help.

#!/bin/ksh

pathvar='/home/WSJ091305.txt'
echo "r->[${pathvar%%.*}]"
echo "h->[${pathvar%/*}]"
echo "t->[${pathvar##*/}]"
echo "e->[${pathvar#*.}]"

Now I'm getting this:

r->[/home/WSJ091305]
h->[/home]
t->[WSJ091305.txt]
e->[txt]

Is there a way to only get the results as with the csh?

well.... it's for you to see HOW it can be used.

Thanks for the assist. I appreciate it.

I was able to get what I needed. Could you point me to some documentation that explains the commands you used to get this? Specifically, what all the characters do? I'm unfamiliar with them. Thanks so much for your help.

Read the manuals.

In man ksh under the section Parameters

In man sh under the section Parameter Expansion

That explains it quite nicely. Thanx