Skip to content

Instantly share code, notes, and snippets.

@millionfor
Last active June 21, 2022 08:11
Show Gist options
  • Save millionfor/6a5b6d4f853afa607378fbec08e326b6 to your computer and use it in GitHub Desktop.
Save millionfor/6a5b6d4f853afa607378fbec08e326b6 to your computer and use it in GitHub Desktop.
#!/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