Jak v sh prevest relativni cestu na absolutni?

Petr Klima klima na jihomilk.cz
Pátek Duben 8 14:38:29 CEST 2005


ph na rook.cz napsal(a):

>>jestli /xxx/yyy/zzz a /xxx/../xxx/yyy/../yyy/zzz jsou stejne soubory 
>>(teda spis cesty ...)
>>
>>! nepotrebuji porovnat cisla i-node
>>
>>potrebuji to prevest na absolutni cestu a porovnat jako stringy a 
>>pripadne dal pouzit ...
>>    
>>
>
>   Ač na to nevypadá, zkuste 'readlink -f'. :)
>  
>
hm ... pan je znalec ... to je videt na prvni pohled  ;-)

sice jen na Linuxu (RHEL-3 - package coreutils ),  HP/UX a  Solaris to 
nemaji ... musim sehnat

Jen tak pro sport ... neznate nejake prenositelne reseni ...?



PRIKLAD

$ cd /tmp/
$ readlink -f /etc/
/etc
$ readlink -f ../etc/
/etc
$ readlink -f ../etc/pro
profile    profile.d  protocols
$ readlink -f ../etc/profile.d/..
/etc

A DOKONCE

$ readlink -f ~/../../etc/profile.d/..
/etc

to je labuz ...



Další informace o konferenci Linux