Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 SMI; site ur-laser.uucp Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!rochester!ur-laser!nitin From: nitin@ur-laser.uucp (Nitin Sampat) Newsgroups: net.sources Subject: interactive rmdir : deletes non-empty directories Message-ID: <323@ur-laser.uucp> Date: Mon, 9-Dec-85 16:16:18 EST Article-I.D.: ur-laser.323 Posted: Mon Dec 9 16:16:18 1985 Date-Received: Thu, 12-Dec-85 06:34:46 EST Organization: Lab for Laser Energetics, Univ. of Rochester Lines: 49 Here is an interactive rmdir Bourne shell script which prompts user for confirmation whenever he/she attempts to delete a non-empty directory. I found this useful because I used to use the /bin/rm -r to delete such directories. However, if I made a mistake with this command it would delete all my files !! This shell script is the safe way out. Also, its convenient. Please test in a separate directory before use !! NO GAURENTEES No Copyright but credit me out of courtesy if you don't mind ! To use shell this file ; -------------------------CUT HERE---------------------------------------- #!/bin/sh #FILE: rmdir #AUTHOR: Nitin Sampat {seismo.allegra}!rochester!ur-laser!nitin.uucp #DATE: Dec 7, 1985 #PURPOSE: To remove directories even if there are files # in them but to interactively seek confirmation # first. #NOTE: If this file resides in /usr/you/bin read from # this directory first. i.e Check your PATH ! # To execute , shell this file #PUBLIC DOMAIN : No gaurentees !!!!! case $# in 0) echo "Usage: rmdir dir";; esac for i do if /bin/rmdir $i #first run original rmdir on argument(s) then echo "$i directory deleted " #rmdir successful else #if original rmdir unsuccessful if test -d $i #test if argument is a dir then echo -n "Do you really want to delete $i (y/n): " #prompt confirmation read answer case $answer in y) /bin/rm -r $i #rmdir dir recursively #if user confirms deletion echo "$i directory deleted";; *) ;; esac fi fi done