Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i have the absolute name ?

Status
Not open for further replies.

cantubas

Programmer
Jan 8, 2004
45
FR
how can i have the absolute name of a file
i want to find a function that transforms
../name in /home/etc/name
 
Try this:
curdir=`pwd`; parent=`dirname "$curdir"`
echo "$parent/name"

Hope This Help
PH.
 
In ksh you can try this:
Code:
f=../name
realf=$(cd ..;pwd -P)/$(basename $f)
echo "$f is $realf"
Anyway: man cd;man pwd;man basename;man dirname

Hope This Help
PH.
 
[tt]
relFile=../name
rep=`dirname $relFile`
absFile=`cd $rep ; pwd`/`basename $relFile`
echo "$relFile is $absFile"
[/tt]
the same with ksh
[tt]
relFile=../name
$(cd $(dirname $relFile) ; pwd)/$(basename $relFile)
echo "$relFile is $absFile"
[/tt]

Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top