Skip to content

Instantly share code, notes, and snippets.

@verityj
Last active June 21, 2023 11:22
Show Gist options
  • Save verityj/32d913c5c506b0a1b441826217ba42ac to your computer and use it in GitHub Desktop.
Save verityj/32d913c5c506b0a1b441826217ba42ac to your computer and use it in GitHub Desktop.
Shell script: search in specified location for a file name string (not case sensitive) - do not show errors
#!/bin/zsh
# Written by: VerityJ
# Published on: https://gist.github.com/verityj
#
# Usage: ./find-here.sh location search-string
# search-string does not need " or *
if [ -z "$2" ]
then
echo "Usage: ./find-here.sh <location> <search-string> (note: no need for \" or *)"
echo "<location> example: ~ (user home) or . (current directory)"
exit 0
fi
printf "\nSearching in '$1' for \"*$2*\" (case-insensitive) ...\n\n"
find $1 -iname "*$2*" -not -path "/System/Volumes/Data/*" -print 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment