Rmfind
Da Slacky.eu.
Versione delle 11:46, 12 set 2006, autore: L1q1d (Discussione | contributi)
Descrizione
Questo script esegue una ricerca di tutti i file che corrispondono al PATTERN scritto dall'utente come argomento e li rimuove tutti in un colpo solo, questo strumento è utile per rimuovere file come Thumbs.db e Desktop.ini presenti nel sistema dopo la migrazione di directory da Windows a Linux
Script
#!/bin/bash
# RMFIND - find and remove any file as specified by user
# script coded by SONiC 29/12/2005
# version 0.2
MSG_OPT="rmfind -bef\\174p\\174h\\174v \\474PATTERN\\476"
MSG_HELP="Usage: rmfind [OPTIONS] [PATTERN]\n\n rmfind - find and remove all files as specified in PATTERN.\n\n Options:\n\t -b\t\t find and remove any file that begins by PATTERN\n\t -e\t\t find and remove any file that ends by PATTERN\n\t -p\t\t find and remove any file named as PATTERN\n\t -f\t\t find any file without rimoving it\n\t -h, --help\t this help page\n\t -v, --version\t display version and exit\n\nReport bugs to \\474sonic81@email.it\\476"
MSG_USAGE="Usage: $MSG_OPT"
MSG_VERSION="rmfind 0.2 - script coded by SONiC"
if [ "$1" = '-h' ]||[ "$1" = '--help' ]; then
echo -e $MSG_HELP
exit 1
fi
if [ "$1" = '-v' ]||[ "$1" = '--version' ]; then
echo -e $MSG_VERSION
exit 1
fi
if [ -z "$1" ]||[ -z "$2" ]; then
echo -e $MSG_USAGE
exit 1
fi
#Use this to change remove options
A='rm -vfr';
case "$1" in
'-b')
find . -name "$2*" -exec $A {} \;
;;
'-e')
find . -name "*$2" -exec $A {} \;
;;
'-be'|'-eb')
find . -name "*$2*" -exec $A {} \;
;;
'-p')
find . -name "$2" -exec $A {} \;
;;
'-f'|'-fp'|'-pf')
find . -name "$2"
exit 0
;;
'-fb'|'-bf')
find . -name "$2*"
exit 0
;;
'-fe'|'-ef')
find . -name "*$2"
exit 0
;;
'-feb'|'-fbe'|'-bef'|'-bfe'|'-ebf'|'-efb')
find . -name "*$2*"
exit 0
;;
*)
echo -e $MSG_USAGE
exit 2
esac
exit 0
- Data: 03 Jun 2006
- Autore: Sonic
- Versione: 0.2