Linux:Script to find files
Wednesday, August 17th, 2011I regularly have to find where a file is located and usually use find:
find . | grep
Where
#!/bin/sh if [ $# -lt 1 ]; then echo 1>&2 Usage: $0 "" exit 127 fi icase= while [ $# -ge 1 ]; do case $1 in -i) icase=$1;; *) search=$1 ;; esac shift done find . | grep $icase $search
This is just a simple script which I have named ffind that searches starting from the current directory. This lets me search with the following commands:
ffind bak$
This will search for all files that end with “bak” .
ffind -i edr
This will search for all files with “edr” regardless of case