Linked Questions

48 votes
2 answers
38k views

How can I take any given path in bash and convert it to it's canonical form, dereferencing any symbolic links that may be contained within the path? For example: ~$ mkdir /tmp/symtest ~$ cd /tmp/...
David Dean's user avatar
  • 7,731
1 vote
1 answer
2k views

In Shell script, How can I check if /bin/sh is softlink'ed to dash or bash, I may have /bin/sh -> dash or /bin/sh -> bash
rodee's user avatar
  • 3,221
2 votes
2 answers
316 views

I cannot work this out, seems my command in awk is not good enough: Basically I'd like to extract information from a simple Linux ls -l: ls -l /etc/alternatives/java lrwxrwxrwx. 1 root root 29 Apr ...
Michael Mao's user avatar
  • 10.3k
0 votes
0 answers
100 views

Is there a way to portably (at least Linux and macOS) get the destination of a symlink in a (Posix) shell script? In an old program, I found ls -lad "bin" 2> /dev/null | awk '{ printf (&...
olebole's user avatar
  • 593
1102 votes
36 answers
1.9m views

Is there an easy way I can print the full path of file.txt ? file.txt = /nfs/an/disks/jj/home/dir/file.txt The <command> dir> <command> file.txt should print /nfs/an/disks/jj/home/...
Jean's user avatar
  • 23k
456 votes
26 answers
174k views

On Linux, the readlink utility accepts an option -f that follows additional links. This doesn't seem to work on Mac and possibly BSD based systems. What would the equivalent be? Here's some debug ...
troelskn's user avatar
  • 118k
227 votes
6 answers
199k views

I mounted the container with this parameter: -v /home/test/:/home/test Inside /home/test in the host there is a symbolic link pointing to a /mnt/ folder. But that link, although can be seen where ...
lapinkoira's user avatar
  • 9,108
48 votes
3 answers
78k views

Is it possible, executing a file symlinked in /usr/local/bin folder, to get the absolute path of original script? Well, .. I know where original file is, and I know it because I am linkging it. But, .....
sensorario's user avatar
  • 21.9k
11 votes
5 answers
21k views

When I need to get path to the script file inside script itself I use something like this: `dirname $0` that works file until I call the script through sym link to it. In that case above code prints ...
Ma99uS's user avatar
  • 11k
7 votes
4 answers
2k views

Finding the java binaries can be painful: which java gives /usr/bin/java lh $(which java) gives /usr/bin/java -> /etc/alternatives/java lh /etc/alternatives/java gives /etc/alternatives/java -> /...
Edward's user avatar
  • 4,701
8 votes
3 answers
2k views

I mean I want to use unset that is not a shell function itself. If I could do that, I could make sure that command is pure by running #!/bin/sh { \unset -f unalias command [; \unalias unset command [ ...
jarno's user avatar
  • 882
1 vote
2 answers
2k views

I am trying to truncate a string in bash, specifically to get into the directory of an executable linked by a symlink. For example: [alva@brnzn ~ $] ls -algh $(which python3.4) lrwxr-xr-x 1 admin ...
alva's user avatar
  • 72
0 votes
1 answer
3k views

The following line introduces the local variable PROGUARD_HOME within a shell script: PROGUARD_HOME=`dirname "$0"`/.. This points to the parent folder of the shell script. The script executes ...
JJD's user avatar
  • 52.7k