Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [[ "$1" = -h || "$1" = —help ]]
- then
- echo "Usage: clearPath.sh [path]"
- echo.
- echo The script displays the directories names with executable files.
- echo If [path] is empty script displays the directories names PATH
- exit 0
- fi
- if [ -z "$1" ]
- then
- currentPath="$PATH"
- else
- currentPath="$1"
- fi
- LFS=':'
- result=""
- echo $currentPath
- echo ""
- for folder in $currentPath
- do
- echo "$folder"
- if [[ ! -d "$folder" || "$result": == *:$(readlink -f "$folder"):* ]]
- then
- continue
- fi
- firstChar=$(echo "$folder" | cut -c 1)
- if [[ "$firstChar" == "." || "$firstChar" == "~" ]]
- then
- continue
- fi
- for file in $folder
- do
- if [[ -x "$file" ]]
- then
- result=$result:$(readlink -f "$folder")
- break
- fi
- done
- done
- IFS=' '
- echo "${result#:}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement