Unix Shell - Re: full path of a script

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2007 > Re: full path of a script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: full path of a script
Miles

2007-09-24, 1:26 pm

On Sep 24, 8:11 am, Martin Krischik <krisc...@users.sourceforge.net>
wrote:
> Hello.
>
> currently use the following code to get the full path of the currently
> running script:
>
> pushd "$(dirname ${0})";
> typeset -r My_Dir=$(pwd);
> popd;
>
> But somehow I think there must be a better way. So is there?
>
> Martin
> --
> mailto://krisc...@users.sourceforge.net
> Ada programming at:http://ada.krischik.com


I think you want:
${variable%/*}

>TEST="/home/unxsa/csm/gdsh"
>echo ${TEST%/*}

/home/unxsa/csm

Miles




Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com