Skip to content

Instantly share code, notes, and snippets.

@nvie
Created July 18, 2012 08:00
Show Gist options
  • Save nvie/3134932 to your computer and use it in GitHub Desktop.
Save nvie/3134932 to your computer and use it in GitHub Desktop.
Finds files by extension starting from the current working directory.
#!/bin/sh
set -e
extensions=$*
main() {
if [ -z "$extensions" ]; then
find .
else
echo "find . $(build_find_command_arguments)" | sh
fi
}
build_find_command_arguments() {
args=""
for ext in $extensions; do
args="${args} -o -name '*.${ext}'"
done
echo $args | cut -c 4-
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment