I am apparently still suffering the unintentional side effects of my long-ago decision to dump everything from coreutils, bsd-games and util-linux back into my list. Because yesterday I realized I still had a zero-byte file for
realpath hiding in my vimwiki folder.😡
These things are like rabbits. Turn your back and they’ve multiplied.
realpath belongs to the coreutils family, and I am not being kind by suggesting it has no real function or can’t solve an issue. Remember when I prattled endlessly about basename and dirname?
realpath solves some of the issues that I mentioned with those programs.
Here’s what it looks like in action:
kmandla@6m47421: ~/temp$ realpath test.txt /home/kmandla/temp/test.txt kmandla@6m47421: ~/temp$ realpath . /home/kmandla/temp
Oh, K.Mandla. Thank you sooo much for showing that. Thank you sooo much for solving my existential crisis with
realpath. K.Mandla, your grimy little blog is a fount of wisdom.
Hey, my little blog may be grimy, but at least it’s legit, original content. Can’t say that about a lot of Linux “news” sites.👿
Back to business:
realpath, as you can see above, returns the path of the target you specify, or as the man page so verbosely explains, “prints the resolved path.”
Before you close this tab, here’s one more example:
kmandla@6m47421: ~$ realpath sdb1 /media/sdb1
O-ho. What’s this? Well, I keep a symlink in my home directory that targets a mount point — with that, I can abbreviate
mount /media/sdb1 to just
mount sdb1, no difference.
realpath returns the real path🙄 of the symlink, rather than just its location in my home folder. Now we’re cooking.
realpath will accept a few flags, but they strike me as particularly discrete cases for links, and tune
realpath‘s output more than I would ever need. Double-check them if you feel you may want them.
So there it is. And unless I’m mistaken — again — this really is the last title from coreutils.