Advertisement
goodoldlameme

Untitled

Nov 18th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. help(){
  4. echo "This script displays the purified PATH"
  5. exit
  6. }
  7. solve(){
  8. IFS=:
  9. for directory in $path
  10. do
  11. if [ -d "$directory" ]
  12. then
  13. for file in $directory/*
  14. do
  15. if [ -x "$file" ]
  16. then
  17. cleanpath="$cleanpath"":""$directory"
  18. break
  19. fi
  20. done
  21. fi
  22. done
  23.  
  24. cleanpath=${cleanpath#:}
  25. echo "$cleanpath"
  26. }
  27.  
  28. if [[ $1 = "--help" || $1 = "-h" ]]; then help; fi
  29. if [[ -n $1 ]]; then
  30. path=$1
  31. solve
  32. else
  33. path=$PATH
  34. solve
  35. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement