Skip to main content
20 events
when toggle format what by license comment
May 12, 2022 at 20:52 comment added JL Peyret Note that this supports reading the absolute path of a symlink, rather than what the symplink points to, which using realpath does not.
Mar 15, 2018 at 5:38 comment added Gary Gauh how to handle symbolic link
Aug 24, 2017 at 20:55 history edited peterh CC BY-SA 3.0
added 98 characters in body
S Aug 24, 2017 at 19:06 history suggested Tom Dibble CC BY-SA 3.0
Adds handling of relative directories which end with a '..' or '.'
Aug 24, 2017 at 17:27 review Suggested edits
S Aug 24, 2017 at 19:06
Oct 7, 2015 at 11:11 review Suggested edits
Oct 7, 2015 at 11:38
Nov 27, 2014 at 11:47 comment added mc0e At the cost of being larger, this would be much better if it gave errors when appropriate, including when acting on an empty string as input.
Nov 27, 2014 at 11:45 comment added mc0e @marbu realpath is not present on Ubuntu 14.04, or on Debian Wheezy. It may become somewhat standard over time, but it's certainly not now. Also note that the OP didn't say anything about linux or GNU. Bash is more widely used than that.
Sep 30, 2014 at 17:42 comment added slf thanks, but personally I made it echo -n just to make it more clipboard friendly
Apr 11, 2014 at 11:54 comment added peterh @AlexanderKlimetschek. You are absolutely right. I wanted to keep the stub simple. Then others can expand on it according to their needs. Exactly as you've done. Nice!.
Apr 11, 2014 at 2:13 comment added Alexander Klimetschek This only works for directories (since there is no else) and cannot cope with ".." and ".". See my answer that should handle everything: stackoverflow.com/a/23002317/2709
Mar 6, 2014 at 11:39 comment added wjv Well, it seems at least that Continuum Analytics (makers of the Anaconda Python distribution) liked this answer. It is implemented (with a reference linking back here) in their "activate" script, which is used to activate virtual environments created by the conda tool. So… good one!
Feb 6, 2014 at 22:22 comment added marbu I would like to add that realpath comes from coreutils package, which also contains tools such as who, touch or cat. It's quite standar set of GNU tools, so you can be quite sure that this is installed on almost any linux based machine.That said, you are right: there are 2 issues with it: i) you will likely miss it in default install on non GNU unix systems (like OpenBSD) ii) this tools was introduced in version 8.15 (so it's quite new, from 2012), so you will miss it on long term stable systems (like RHEL 6).
Feb 6, 2014 at 15:42 comment added dhardy You've got me there. Still, realpath is what I was after when I asked the question, and it's standard enough to be available as a package on all Linux distributions I've used recently.
Feb 4, 2014 at 13:53 comment added peterh Neither realpath nor realink is 'a standard Unix utility' so if that's what you were after then you've gone with the wrong answer.
Feb 4, 2014 at 13:15 comment added dhardy Well, nolan6000, I included a capable (if inelegant) script to do this in the question, which then asked if there was a standard Unix utility to do the same thing. I'm surprised by all the other answers too to be honest — realpath covers the original use-case and readlink some related ones, so yet another answer doesn't help.
Jan 26, 2014 at 11:39 comment added peterh @dhardy. Not sure I understand your comment. What is it in the solution proposed here that excludes use from an interactive environment? ... btw, just like all the other alternative answers presented on this page.
Jan 26, 2014 at 11:39 history edited peterh CC BY-SA 3.0
added 414 characters in body
Jan 25, 2014 at 17:19 comment added dhardy Nice function, but apparently you didn't understand the question. I wanted something for interactive use, not scripts.
Jan 17, 2014 at 14:24 history answered peterh CC BY-SA 3.0