Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GNU nano 2.5.3 File: chercheText.sh
- #!/bin/bash
- function chercherText {
- local code=1
- for file in $(find $1 -type f -mtime -7 2> /dev/null); do
- if file $file | grep -q "text"; then
- echo $file
- code=0
- fi
- done
- return $code
- }
- fout="/dev/stdout"
- while getopts "hf" option; do
- case $option in
- h)
- echo "Usage : chercheText.sh [-h] [-f] [rep [...]]" >> $fout
- exit 2
- ;;
- f)
- fout=chercherText.$(date +"%d_%m_%Y")
- rm $fout 2> /dev/null
- touch $fout
- ;;
- *)
- echo "Options invalides" > /dev/stderr
- echo $usage > /dev/stderr
- exit 1
- ;;
- esac
- done
- shift $(($OPTIND -1))
- code=1
- case $# in
- 0)
- chercherText '.'
- exit $?
- ;;
- 1)
- if [ -d $1 ]; then
- chercherText $1
- exit $?
- else
- echo "$1 n'est pas un repertoire" > /dev/stderr
- exit 2
- fi
- ;;
- *)
- for file in $*; do
- if [ -d $file ]; then
- echo "Repertoire : $file" >> $fout
- chercherText $file
- code=$?
- else
- echo "$file n'est pas un repertoire" > /dev/stderr
- fi
- done
- ;;
- esac
- exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement