Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #init path
- if [[ -z "$1" ]]
- then
- path=$PATH
- else
- path=$1
- fi
- newPath=""
- if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]
- then
- echo This script is clearing PATH directory
- exit 0;
- fi
- IFS=":" read -ra h<<<"$path"
- for i in "${h[@]}"; do
- if [ -d "$1" ]
- then
- for path in $(find "$i" -maxdepth 1 -type f -executable)
- do
- if ((${#newPath} == 0 ))
- then
- newPath=$i
- elif [[ $newPath != *"$i"* ]]
- then
- newPath=$newPath":"$i
- fi
- done
- fi
- done
- echo "$newPath"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement