home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.questions:15381 comp.unix.misc:4898
- Path: sparky!uunet!cs.utexas.edu!uwm.edu!rutgers!rochester!galileo.cc.rochester.edu!ee.rochester.edu!btoy1!mrbulli
- From: mrbulli@btoy1.rochester.NY.US (Mr. Bulli (private account))
- Newsgroups: comp.unix.questions,comp.unix.misc
- Subject: Re: Dumb Question...
- Message-ID: <1993Jan10.110454.6961@btoy1.rochester.NY.US>
- Date: 10 Jan 93 11:04:54 GMT
- References: <1993Jan9.003757.25783@xvt.com>
- Reply-To: mrbulli@btoy1.rochester.NY.US
- Distribution: usa
- Organization: Private UUCP site
- Lines: 95
- X-Newsreader: TIN [version 1.1 PL8]
-
- On 9 Jan 93 00:37:57 GMT Jack Unrue (jack@xvt.com) wrote:
- : ...
- : It is better to make an alias using a name that is easily associated with
- : the intended action but not the same as any system command. For instance,
-
- : alias remove "rm -i"
-
- : This has the benefit that naive users moving to another system will not find
- : the 'remove' command and consequently won't get burned.
-
-
- : ----------------------------------------------------------------
- : Any opinions expressed are my own and not those of XVT Software.
- : ----------------------------------------------------------------
- : Jack D. Unrue
- : jack@xvt.com
- : junrue@nyx.cs.du.edu
-
- Here is a little script that illustrates this principle:
- -------- Cut here --------
- : use /bin/sh
- # @(#) can - copy file into $HOME/Trash instead of really removing
- # @(#) them
- # @(#) From "Tricks of the Unix Masters"
-
- # Adapt these to the values correct for your system
- CAN=${HOME}/Trash
- RM="/bin/rm -f"
- MV="/bin/mv"
-
- if [ ! -d ${CAN} ]
- then
- mkdir ${CAN}
- fi
-
- if [ $# -eq 0 ]
- then
- echo "Usage: can [-l|-r|-h] file [file ...]"
- exit 1
- fi
-
-
- while getopts lrh OPTION
- do
- case ${OPTION} in
- l)
- echo "${CAN}:"
- ls -lsAFR ${CAN}
- exit 0
- ;;
-
- r)
- echo "Cleaning up ${CAN}"
- find ${CAN} -exec ${RM} '{}' ';'
- exit 0
- ;;
-
- h|\?)
- echo "Usage: can [-l|-r|-h] file [file ...]"
- exit 0
- ;;
- esac
- done
- shift `expr $OPTIND - 1`
-
- ${MV} $* ${CAN}
- -------- Cut here --------
- CAN(1) LOCAL COMMANDS CAN(1)
-
- NAME
- can
-
- SYNOPSIS
- can [options] file [file ...]
-
- DESCRIPTION
- can moves file(s) to $HOME/Trash instead of really remo-
- ving them. It should therefore be used in place of "rm".
-
- OPTIONS
- -l List contents of $HOME/Trash
- -r Clean up $HOME/Trash
- -h Show usage
- -------- Cut here --------
-
- If you use "can" instead of "rm" you always have the file(s) available in
- a temporary repository and can restore them from there. But beware - once
- they are deleted from there you're finished ...
- --
- ______ __ _ _
- / / / ) // //
- / /_ __________ __. _ /--< . . // // o ____ _, _ __
- (_/ / /_(_) / / / <_(_/|_/_) /___/_(_/_</_</_<_/ / <_(_)_</_/ (_
- UUCP: ..rutgers!ur-valhalla!btoy1!mrbulli /| Compu$erve:
- Internet: mrbulli@btoy1.rochester.NY.US |/ 76535,2221
-