Skip to content

Instantly share code, notes, and snippets.

@ramimassoud
Created August 28, 2011 03:24
Show Gist options
  • Save ramimassoud/1176199 to your computer and use it in GitHub Desktop.
Save ramimassoud/1176199 to your computer and use it in GitHub Desktop.
Some quick bash function examples
# -*- mode: shell-script; -*-
# Search for matching files; list, verify, and delete them
function rmf {
name=$1
find . -type f -iname "$name"
echo " "
echo "Remove listed files? y/n"
read answer
if [ "$answer" = "y" ]; then
find . -type f -iname "$name" -exec rm -f {} \;
fi
}
# Search for matching directories; list, verify, and delete them
function rmd {
name=$1
find . -type d -iname "$name"
echo " "
echo "Remove listed files? y/n"
read answer
if [ "$answer" = "y" ]; then
find . -type f -iname "$name" -exec rm -fr {} \;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment