Skip to content

Instantly share code, notes, and snippets.

@xerrni
Last active March 26, 2017 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xerrni/e2f7b5c2fb793b90b4f1a38d56ce9dde to your computer and use it in GitHub Desktop.
Save xerrni/e2f7b5c2fb793b90b4f1a38d56ce9dde to your computer and use it in GitHub Desktop.
SOE LAB1 ZAD2
#!/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