Created
August 28, 2011 03:24
-
-
Save ramimassoud/1176199 to your computer and use it in GitHub Desktop.
Some quick bash function examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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