|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Hi there, Is there any way to obtain a real path from a weird path. For example : Code:
/foo/../bar/ -> /bar/ /foo/. -> /foo/ Thanks in advance Santiago Last edited by chebarbudo; 02-11-2009 at 03:11 AM.. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Code:
$ bash -c "cd /foo/../bar/ ; pwd" /bar Last edited by otheus; 11-13-2008 at 05:42 AM.. |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Great job ! Thank you
It looks so simple ! I would never have thought about it. What if we want to clean the path to a file ? |
|
#4
|
|||
|
|||
|
truncate the file from the path with dirname and basename
# dirname /foo/../bar/file /foo/../bar # basename /foo/../bar/file file clear the path and stick it together again |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Great job again thx.
I'm new in this forum. Is there any way to flag my question as "solved". This feature helps people who search something to select only "solved" threads. |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Here is another solution that I just found: Code:
sudo aptitude install realpath realpath -s /home/../var/./run//motd /var/run/motd Last edited by chebarbudo; 02-11-2009 at 03:10 AM.. |
| Sponsored Links | ||
|
![]() |
| Tags |
| basename, dirname, path |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Kernel Modules Not geting built | rupeshkp728 | UNIX for Advanced & Expert Users | 1 | 01-28-2012 11:34 AM |
| Geting a value dynamically from topas | jayadeava | AIX | 4 | 06-03-2011 11:26 AM |
| geting a value out of awk script | skyineyes | Shell Programming and Scripting | 2 | 05-12-2010 10:49 AM |
| Getting real path to directory | kandrewo | UNIX for Advanced & Expert Users | 7 | 12-18-2009 03:05 PM |
| geting server name(ipaddress) | babu@shell | Shell Programming and Scripting | 1 | 10-24-2006 09:01 AM |
|
|