Last active
March 26, 2017 21:53
-
-
Save xerrni/e2f7b5c2fb793b90b4f1a38d56ce9dde to your computer and use it in GitHub Desktop.
SOE LAB1 ZAD2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
help="Poprawne użycie:\narg1 - wyrazenie\narg2 - rozszerzenie pliku\narg3 - katalog, w ktorym skrypt bedzie szukal pliku okreslonego typu." | |
if [ "$#" -ne 3 ]; then | |
echo "podaj 3 argumenty" | |
echo -e $help | |
exit 1 | |
fi | |
if [ ! -d "$3" ]; then | |
echo "Trzeci argument: \"$3\" powinien być ścieżką do katalogu" | |
echo -e $help | |
exit 2 | |
fi | |
if [ ! -r "$3" ]; then | |
echo "Nie masz uprawnien do przegladania katalogu." | |
exit 3 | |
fi | |
if [ ! -x "$3" ]; then | |
echo "Nie masz uprawnien do przegladania katalogu." | |
exit 3 | |
fi | |
find "$3" -name "*$2" -print0 | xargs -0 grep -l "$1" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment