I feel stupid -- determine the full path to a file

Shane Hathaway shane at hathawaymix.org
Thu Dec 6 13:27:05 MST 2007

Michael L Torrie wrote:
> Bash is just wonderful at putting existing tools together using
> processes and pipes.  While I could do everything in Python in this
> case, bash is the more comfortable language for doing this kind of
> thing.  Especially since in my script, most of what I need to do is run
> other commands, like, fdisk, fsck, mount, and so forth.

I agree that bash is frequently easier, but its documentation is
scattered and IMHO bash is much more prone to bugs.  Even the earlier
one-liner has a significant bug; it will fail if the path happens to
contain a space.  Fortunately there's an obvious solution:

abspath=$(readlink -f "$fn")

For me, the numerous warts like this usually tip the balance in favor of
a general purpose language.


More information about the PLUG mailing list