3
votes
1answer
78 views

Test for link with trailing slash?

I created in /tmp/test/ mkdir somedir ln -s somedir/ somelink I want to loop through only directories: for file in */ ; do if [[ -d "$file" && ! -L "$file" ]]; then echo "$file is a ...
2
votes
1answer
75 views

Symlink with @ symbol?

I found that there is a symlink generated by ruby which has a @ sign at the path: default -> /Users/MyUserName/.rvm/rubies/ruby-2.0.0-p247@gemset The folder ...
3
votes
2answers
54 views

Is there a way to condense ../.. parts of a path out programatically?

Say for example I have these types of paths to files in a script: /path/to/some/file/../../file1.txt Is there a command I can call such as readlink that will convert this path to its actual ...
2
votes
1answer
201 views

Canonical paths: why are they needed?

The issue of resolving symlinks (symbolic links) is often addressed on this forum, and on others. Related are the concepts of relative, absolute (or full), and canonical (or resolved) pathnames. Two ...
8
votes
5answers
772 views

Portable way to get script's absolute path?

What is a portable way for a (zsh) script to determine its absolute path? On Linux I use something like mypath=$(readlink -f $0) ...but this is not portable. (E.g., readlink on darwin does not ...
3
votes
1answer
93 views

Symbolic link starting with .#

I have a symlink in one of my directories that has the following name: lrwxrwxrwx 1 XXXX ZZZ 37 Jan 15 18:18 .#perl.org -> XXX@YYY.com.2980:1344441539 I am wondering what this symlink ...
5
votes
1answer
135 views

Can non-canonicalized forms of filesystem paths be significant? (eg. “foo//bar”, “foo/./bar”, and “foo/../bar”)

I have a script for building a particular flavor of GCC cross-compiler. Throughout the script there are many paths that are not in canonical form, such as duplicate path separators (/xxx/foo//bar/yyy) ...
1
vote
1answer
173 views

How to get a list all the “aliases” of a file (including of type directory) efficiently?

How can one get the list of all the aliases of a file (including of type directory) efficiently, given that a file: may have multiple hard links, multipe soft links, multi-level soft links may be ...
4
votes
2answers
1k views

Trailing slashes on symbolic links to directories

I'm trying to emulate the process of path resolution (see man page path_resolution) in unix-like systems. My OS is Linux with GNU coreutils 8.7. In order to clarify the meaning of extra trailing '/' ...
14
votes
4answers
9k views

Converting relative path to absolute path

Is there a *nix command to get absolute(and canonicalized) path from relative path(with current path) or symbolic link?
6
votes
1answer
433 views

Why do some symbolic links affect program behavior?

One thing that has been puzzling me for some time is this: % which halt /sbin/halt % file /sbin/halt /sbin/halt: symbolic link to `reboot' However, executing sudo halt does, of course, not reboot ...