Xioth

Bash - TD1 - argInPath.sh

Jan 25th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.27 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# = 0 ]
  4. then
  5.     echo "Vous n'avez pas passé de paramètre"
  6.     exit 1
  7. else
  8.     myPath=$(echo $PATH | tr ':' '\n')
  9.  
  10.     for arg in $@
  11.     do
  12.         for aPath in $myPath
  13.         do
  14.             if echo "$aPath" | grep -q "$arg"
  15.             then
  16.                 echo "$aPath"
  17.             fi
  18.         done
  19.     done
  20. fi
Add Comment
Please, Sign In to add comment