#!/bin/bash # # finder [Linux edition v0.2] # # find uses 'find' to find stuff, either via a simple # interactive session, or via command-line parameters, # or both. # # Usage: # # interactive: # # finder # # command-line: # # finder {what to find} [{screen/file output] # # As well as big scrolls of permission errors, running as root # also prevents non-root users from using it, obviously. # # I think I originally wrote this because I kept back-to-fronting # the syntax for 'find', and when you want to find something, you # want it NOW. I often find it handy. # # (or @ corz.org 2005-> ;o) # findwhat="$1" output="$2" clear echo echo " finder finds stuff for you" echo " for when the usual methods have failed!" echo if [ "$UID" != "0" ]; then echo " To avoid permission problems, finder runs as root." echo " Please enter your admin password when prompted." echo fi echo " hints: You can use whereis to quickly find applications and locate" echo " to find files that are in the locate database (older than a day)." echo echo " notes: Connected shares will NOT searched." echo if [ -z "$findwhat" ]; then echo " Enter the name of the file or folder to find.." echo " hint: you can use wildcards like.. *.ttf" echo read findwhat fi if [ -z "$findwhat" ]; then echo " If nothingness is what you seek, look elsewhere!" echo exit 1 fi echo echo " searching for: $findwhat" echo if [ -z "$output" ]; then echo " would you like the output to screen or file? [s/f]" echo " hint: you can simply hit to output to screen" echo read output echo fi echo " looking for $findwhat".. echo " hint: press CTRL+C to terminate the find" echo case $output in f) echo " sending results to ~/finder.log" echo "" > ~/finder.log echo echo "finder." `date` >> ~/finder.log echo "results for \"$findwhat\".." >> ~/finder.log echo "" >> ~/finder.log sudo find / -name "$findwhat" -xdev >> ~/finder.log ;; *) echo "" sudo find / -xdev -name "$findwhat" echo "" ;; esac echo echo "find complete!" echo