f5d3a9592fe5fcabd4f904b4e858891557f3f116
[clearscm.git] / bin / findsymlinks.sh
1 #!/bin/bash
2
3 path=$1
4
5 if [ -z "$path" ]; then
6   echo "Usage $0 <path>"
7   exit 1
8 fi
9
10 IFS='/' read -ra components <<< "$path"
11
12 testpath=''
13
14 for component in "${components[@]}"; do
15   [ -z "$component" ] && continue
16
17   testpath="${testpath}/$component"
18
19   if [ -h "$testpath" ]; then
20     echo "$testpath: symbolic link to $(ls -l $testpath | awk '{print $NF}')"
21     testpath=$(readlink -n $testpath)
22   fi
23 done