home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / question / 15381 < prev    next >
Encoding:
Internet Message Format  |  1993-01-09  |  3.0 KB

  1. Xref: sparky comp.unix.questions:15381 comp.unix.misc:4898
  2. Path: sparky!uunet!cs.utexas.edu!uwm.edu!rutgers!rochester!galileo.cc.rochester.edu!ee.rochester.edu!btoy1!mrbulli
  3. From: mrbulli@btoy1.rochester.NY.US (Mr. Bulli (private account))
  4. Newsgroups: comp.unix.questions,comp.unix.misc
  5. Subject: Re: Dumb Question...
  6. Message-ID: <1993Jan10.110454.6961@btoy1.rochester.NY.US>
  7. Date: 10 Jan 93 11:04:54 GMT
  8. References: <1993Jan9.003757.25783@xvt.com>
  9. Reply-To: mrbulli@btoy1.rochester.NY.US
  10. Distribution: usa
  11. Organization: Private UUCP site
  12. Lines: 95
  13. X-Newsreader: TIN [version 1.1 PL8]
  14.  
  15. On 9 Jan 93 00:37:57 GMT Jack Unrue (jack@xvt.com) wrote:
  16. : ...
  17. : It is better to make an alias using a name that is easily associated with
  18. : the intended action but not the same as any system command.  For instance,
  19.  
  20. :     alias remove "rm -i"
  21.  
  22. : This has the benefit that naive users moving to another system will not find
  23. : the 'remove' command and consequently won't get burned.
  24.  
  25.  
  26. : ----------------------------------------------------------------
  27. : Any opinions expressed are my own and not those of XVT Software.
  28. : ----------------------------------------------------------------
  29. : Jack D. Unrue
  30. : jack@xvt.com
  31. : junrue@nyx.cs.du.edu
  32.  
  33. Here is a little script that illustrates this principle:
  34. -------- Cut here --------
  35. : use /bin/sh
  36. # @(#) can - copy file into $HOME/Trash instead of really removing
  37. # @(#)       them
  38. # @(#)         From "Tricks of the Unix Masters"
  39.  
  40. # Adapt these to the values correct for your system
  41. CAN=${HOME}/Trash
  42. RM="/bin/rm -f"
  43. MV="/bin/mv"
  44.  
  45. if [ ! -d ${CAN} ]
  46. then
  47.     mkdir ${CAN}
  48. fi
  49.  
  50. if [ $# -eq 0 ]
  51. then
  52.     echo "Usage: can [-l|-r|-h] file [file ...]"
  53.     exit 1
  54. fi
  55.  
  56.  
  57. while getopts lrh OPTION
  58. do
  59.     case ${OPTION} in
  60.         l)
  61.             echo "${CAN}:"
  62.             ls -lsAFR ${CAN}
  63.             exit 0
  64.             ;;
  65.  
  66.         r)
  67.             echo "Cleaning up ${CAN}"
  68.             find ${CAN} -exec ${RM} '{}' ';'
  69.             exit 0
  70.             ;;
  71.  
  72.         h|\?)
  73.             echo "Usage: can [-l|-r|-h] file [file ...]"
  74.             exit 0
  75.             ;;
  76.     esac
  77. done
  78. shift `expr $OPTIND - 1`
  79.  
  80. ${MV} $* ${CAN}
  81. -------- Cut here --------
  82. CAN(1)                 LOCAL COMMANDS                    CAN(1)
  83.  
  84. NAME
  85.      can 
  86.  
  87. SYNOPSIS
  88.      can [options] file [file ...]
  89.  
  90. DESCRIPTION
  91.      can moves file(s) to  $HOME/Trash instead of really remo-
  92.      ving them. It should therefore be used in place of "rm".
  93.  
  94. OPTIONS
  95.      -l    List contents of $HOME/Trash
  96.      -r    Clean up $HOME/Trash
  97.      -h    Show usage
  98. -------- Cut here --------
  99.  
  100. If you use "can" instead of "rm" you always have the file(s) available in 
  101. a temporary repository and can restore them from there. But beware - once
  102. they are deleted from there you're finished ...
  103. --
  104.   ______                             __        _  _
  105.     /   /                           /  )      // //                        
  106.    /   /_  __________  __.  _      /--<  . . // // o ____  _,  _  __
  107. (_/   / /_(_) / / / <_(_/|_/_)    /___/_(_/_</_</_<_/ / <_(_)_</_/ (_
  108.        UUCP:     ..rutgers!ur-valhalla!btoy1!mrbulli      /|  Compu$erve:
  109.        Internet:       mrbulli@btoy1.rochester.NY.US     |/    76535,2221
  110.