#### Use example #### [user@host Downloads]$ wtzc http://raoulito.info/plugins/pidgin_screenshot/pidgin-sendscreenshot-0.6-3.tar.gz [user@host pidgin-sendscreenshot-0.6-3]$ ls aclocal.m4 config.h.in INSTALL m4 README AUTHORS config.sub install-sh Makefile.am src build-aux configure intltool-extract.in Makefile.in VERSION ChangeLog configure.ac intltool-merge.in missing config COPYING intltool-update.in NEWS config.guess depcomp ltmain.sh po [user@host pidgin-sendscreenshot-0.6-3]$ removedir You are about to delete the current directory /home/user/Downloads/pidgin-sendscreenshot-0.6-3/ Are you sure? yes [user@host Downloads]$
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
removedir () { echo "You are about to delete the current directory $PWD Are you sure?"; read human; if [[ "$human" = "yes" ]]; then blah=$(echo "$PWD" | sed 's/ /\\ /g'); foo=$(basename "$blah"); rm -Rf ../$foo/ && cd ..; else echo "I'm watching you" | pv -qL 10; fi; }
removedir(){ read -p "You are about to delete the current directory $PWD Are you sure? " human;if [ "$human" = "yes" ]; then foo=$(basename "$PWD");[ -z "$foo" ] && { echo "Error: Couldn't get working directory" >&2;return 1;}; rm -Rf ../"$foo"/ && cd ..; else echo "I'm watching you" | pv -qL 10; fi; }
Notice the "[ -z $foo ]" part. That checks if the variable $foo is null. If it is null, then the function echoes an error message to stderr and returns a non-zero exit status. Otherwise, it continues. Also notice "read -p". You can specify a prompt for the read command. On a side note, a neat way to get the basename of the current working directory in Bash is to use "${PWD##*/}".