Bash Scripting For Buffoons - Finder Script

Ceri Shaw
02/28/16 04:31:11AM
@ceri-shaw

Finder Script



⇦ Back to 'Bash Scripting For Buffoons'

OK so this one is just plain dumb! It represents an attempt on my part to develop a basic desktop search script. However it relied upon a host of specific directory locations and worked very badly if at all in the majority of cases. Not recommended!



#!/bin/bash
 menu () {
 echo "==========================================================="
 echo "Please enter search extension in the format *.<extension>:-"
 read  FIND
 echo " "
 echo "Please enter your search directory using the absolute path:-"
 read  PLACE
 echo " "
 echo "If you wish to copy the files to the view directory select 'a'."
 echo "If you wish to locate the files select 'b'."
 echo "If you wish to locate and copy the files  select 'c'."
 echo " "
 echo "a copy" $FIND "in" $PLACE
 echo "b locate" $FIND "in" $PLACE
 echo "c locate and copy" $FIND "in" $PLACE
 echo " "
 read  NAME
 case  "$NAME" in
 a) find $PLACE -iname $FIND  2> /dev/null -exec cp -f --target-directory /home/userone/finder/view  {}  \; ;;
 b) find $PLACE -iname $FIND -ls  >> /home/userone/finder/location 2> /dev/null  ;;
 c) find $PLACE -iname $FIND -ls  >> /home/userone/finder/location 2> /dev/null ; find $PLACE -iname $FIND  2> /dev/null -exec cp -f --target-directory /home/userone/finder/view  {}  \; ;;
 *) echo "Not a valid option!"
 esac
 echo " "
 echo "Done"
 echo " "
  }
 menu
 menu
 exit 0