Last active
June 21, 2022 08:11
-
-
Save millionfor/6a5b6d4f853afa607378fbec08e326b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# vim: set ft=sh fdm=manual ts=2 sw=2 sts=2 tw=85 et: | |
# ======================================================= | |
# Description: Get the real path in the bin directory | |
# Author QuanQuan <millionfor@apache.org> | |
# Created Time Tue, Jun 21, 2022 11:36 | |
# Last Modified Tue, Jun 21, 2022 11:36 | |
# GistID 6a5b6d4f853afa607378fbec08e326b6 | |
# GistURL https://gist.github.com/millionfor/6a5b6d4f853afa607378fbec08e326b6 | |
# ======================================================= | |
set -eu | |
a=`which $1` | |
while [ -h $a ] | |
do | |
b=`ls -ld $a|awk '{print $NF}'` | |
c=`ls -ld $a|awk '{print $(NF-2)}'` | |
[[ $b =~ ^/ ]] && a=$b || a=`dirname $c`/$b | |
done | |
echo $a | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment