Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- help(){
- echo "This script displays the purified PATH"
- exit
- }
- solve(){
- IFS=:
- for directory in $path
- do
- if [ -d "$directory" ]
- then
- for file in $directory/*
- do
- if [ -x "$file" ]
- then
- cleanpath="$cleanpath"":""$directory"
- break
- fi
- done
- fi
- done
- cleanpath=${cleanpath#:}
- echo "$cleanpath"
- }
- if [[ $1 = "--help" || $1 = "-h" ]]; then help; fi
- if [[ -n $1 ]]; then
- path=$1
- solve
- else
- path=$PATH
- solve
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement