Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

test -L checks if a file is a symlink; no need for realpath comparisons (which is slower)


Yeah but what do you do if your are not using shell?

Hint: it's stat(2) (or equivalent in your language library)

Additional hint: if using pythons os.stat set follow_symlinks to false. It recently took me an embarrassing long time to figure out why my script was failing to find symlinks.


but they were using a shell script in this blog though (and, yes, stat(2) is the way to go there)


> checks if a file is a symlink

to expand on that:

"In computing, a symbolic link (also symlink or soft link) is a file whose purpose is to point to a file or directory (called the "target") by specifying a path thereto."




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: