pk a écrit :
Peng Yu wrote:
$0 gives the file name of the script. I could use several shell
command to get the directory where the script is in. But I'm wondering
if there is an easy-to-use variable that refers to the directory where
the script is in?
See this page:
Marc a écrit :
source $(dirname $0)/functions.sh
I usually begin all my scripts with this beast:
absolutiseScripts() { SCRIPTS=$1 ; echo $SCRIPTS | grep -q ^/ ||
SCRIPTS=`dirname $2`/$SCRIPTS ; } ; absolutiseScripts `command -v $0`
`pwd`/. ; while [ -h $SCRIPTS ] ; do absolutiseScripts
On Fri, Feb 12, 2010 at 11:56:49AM +0100, Guillaume Outters wrote:
I usually begin all my scripts with this beast:
absolutiseScripts() { SCRIPTS=$1 ; echo $SCRIPTS | grep -q ^/ ||
SCRIPTS=`dirname $2`/$SCRIPTS ; } ; absolutiseScripts `command -v $0`
`pwd`/. ; while [ -h $SCRIPTS ] ; do
Greg a écrit :
Except that HP-UX 10.20 and HP-UX 11.11 don't have readlink(1).
(Maybe it's added in 11.2x? I don't know.)
You're right. I must admit I made a concession to some GNU coreutils tools on
the platform. I once used some ls -l $SCRIPTS | sed -e 's/.* - //' magic to
replace it (and
Greg Wooledge wrote:
That leaves names which contain -. The tricky part here is that we
can't easily tell whether an extra - is in the symbolic link or in
the target.
imadev:~$ ln -s tmp 'x - y'
imadev:~$ ln -s 'y - tmp' x
imadev:~$ ls -ld x*
lrwxr-xr-x 1 wooledgpgmr 8
Am 12.02.2010 15:39, schrieb Greg Wooledge:
On Fri, Feb 12, 2010 at 02:53:39PM +0100, Bernd Eggink wrote:
I once wrote a more generic shell function for this purpose, see:
http://sudrala.de/en_d/shell-getlink.html
You note that it doesn't handle names containing -, which is true.
I'll get
Greg Wooledge wool...@eeg.ccf.org writes:
And testing:
imadev:~$ file=$HOME/x
imadev:~$ link=$(command ls -l -- $file; printf x)
imadev:~$ link=${link%$'\nx'}
imadev:~$ remove=$file -
imadev:~$ file=${link#*$remove}
This lacks a pair of quotes (${link#*$remove}).
$0 gives the file name of the script. I could use several shell
command to get the directory where the script is in. But I'm wondering
if there is an easy-to-use variable that refers to the directory where
the script is in?
On Fri, 12 Feb 2010, Peng Yu wrote:
$0 gives the file name of the script. I could use several shell
command to get the directory where the script is in. But I'm wondering
if there is an easy-to-use variable that refers to the directory where
the script is in?
$0 normally gives the full
Peng Yu wrote:
$0 gives the file name of the script. I could use several shell
command to get the directory where the script is in. But I'm wondering
if there is an easy-to-use variable that refers to the directory where
the script is in?
See this page:
According to Chris F.A. Johnson on 2/11/2010 4:23 PM:
On Fri, 12 Feb 2010, Peng Yu wrote:
$0 gives the file name of the script. I could use several shell
command to get the directory where the script is in. But I'm wondering
if there is an easy-to-use variable that refers to the directory
On Thu, 11 Feb 2010, Eric Blake wrote:
According to Chris F.A. Johnson on 2/11/2010 4:23 PM:
On Fri, 12 Feb 2010, Peng Yu wrote:
$0 gives the file name of the script. I could use several shell
command to get the directory where the script is in. But I'm wondering
if there is an
12 matches
Mail list logo