Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!ames!ptsfa!ihnp4!inuxc!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.UUCP (Rahul Dhesi) Newsgroups: comp.sources.wanted,comp.sources.d Subject: Re: rm replacement; keep me from clobbering myself Message-ID: <1020@bsu-cs.UUCP> Date: Fri, 21-Aug-87 02:53:47 EDT Article-I.D.: bsu-cs.1020 Posted: Fri Aug 21 02:53:47 1987 Date-Received: Sun, 23-Aug-87 01:38:42 EDT References: <26083@sun.uucp> Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 93 Summary: This is a source posting -- save it! Xref: mnetor comp.sources.wanted:2004 comp.sources.d:1146 In response to the request for preventing accidental deletions, here is a csh script. This will work on a pure vanilla 4.3BSD system straight from Berkeley. (This is not a shar archive -- it's a single C-shell script.) --cut here--cut here--cut here--cut here--cut here--cut here--cut here #!/bin/csh -f #File deletion with options #Rahul Dhesi 1987/02/25 #revised 1987/02/26 if ($#argv < 1) then echo Usage: del file ... exit (1) endif foreach file ($*) again: set type='Delete ['`/usr/bin/file "$file"|/bin/sed -e 's/ / /g'`']? [Yes/No/List/Quit] ' switch ("$type") case '*o such file or*' echo "Could not find $file" goto nextloop breaksw case '*directory*' echo "Skipping $file because it is a directory" goto nextloop breaksw case '*mission denied*' echo "Skipping $file because access to it was denied" goto nextloop breaksw endsw ask: echo -n "$type" set ans=($<) switch ("$ans") case 'y' case 'Y' /bin/rm "$file" if (-e "$file") then echo "Sorry, $file could not be deleted" | \ /bin/sed -e 's/\([^ ]\)/_\1/g' | \ /usr/ucb/more else echo "File $file" has been deleted endif breaksw case 'n' case 'N' echo "Skipping $file" breaksw case 'l' case 'L' switch ("$type") case '*text*' case '*script*' echo '*****' "$file" '*****' /bin/cat -uv "$file" | /usr/ucb/more -10d breaksw case '*empty*' echo "***** File $file is empty *****" echo '<...empty...>' breaksw case '*link to*' echo "***** Searching for printable strings in $file ... ***" /usr/ucb/strings "$file" | /bin/cat -uv | /usr/ucb/more -10dl breaksw case '*zoo archive*' echo -n "***** Archive $file contains: *****" /usr/local/zoo l "$file" | /bin/cat -uv | /usr/ucb/more -10dl breaksw default echo "***** Searching for printable strings in $file ... ***" /usr/ucb/strings "$file" | /bin/cat -uv | /usr/ucb/more -10dl breaksw endsw echo '*****' goto again breaksw case 'q' case 'Q' exit default echo 'Please type the first letter: Y, N, L, or Q' goto ask breaksw endsw nextloop: end exit (0) -- Rahul Dhesi UUCP: {ihnp4,seismo}!{iuvax,pur-ee}!bsu-cs!dhesi