1827807 Members
2698 Online
109969 Solutions
New Discussion

Re: if options in ksh

 
SOLVED
Go to solution
V. Nyga
Honored Contributor

if options in ksh

Hi all,

I have to check in a ksh script if a (users) directory ($HOME/v4_sap) exists.
In c-shell it's like:

'if ( -d $SAPDIR ) then'

What's in k-shell for $HOME/v4_sap?

Thanks in advance
Volkmar
*** Say 'Thanks' with Kudos ***
8 REPLIES 8
Arunvijai_4
Honored Contributor
Solution

Re: if options in ksh

Hi Volkmar,

Check this out,

http://www.context-switch.com/reference/kshref/ch4.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Warren_9
Honored Contributor

Re: if options in ksh

hi,

if [ -d $HOME/v4_sap ]
then
......
fi

GOOD LUCK!!
Chan 007
Honored Contributor

Re: if options in ksh

Hi Volkmar,

What about
SAPDIR=$HOME/v4_sap
if [ -d $SAPDIR ]
then

Chan
Robert-Jan Goossens_1
Honored Contributor

Re: if options in ksh

Hi Vo,

something like below example.

if [ ! -d $SAPDIR ]
then
echo "Destination directory : $SAPDIR does not exist, unable to continue !" | tee -a $histlog
exit 1
fi

Best regards,
Robert-Jan
V. Nyga
Honored Contributor

Re: if options in ksh

So I missed the '[' ']' in ksh.

Thanks Arun and Warren!
Always searched the options in itrc, but found nothing.

V.
*** Say 'Thanks' with Kudos ***
Peter Godron
Honored Contributor

Re: if options in ksh

Volkmar,
You are nearly there, just need square brackets.

if [ -d $HOME/v4_sap ]
then
echo "found"
else
echo "Not found"
fi
V. Nyga
Honored Contributor

Re: if options in ksh

Yep - it seemed quite too simple ;-))
The same options only other brakets ...
*** Say 'Thanks' with Kudos ***
V. Nyga
Honored Contributor

Re: if options in ksh

Great forum
Thanks to all!
*** Say 'Thanks' with Kudos ***