ch14 07


A Faster Way to Remove Files Interactively (Unix Power Tools, 3rd Edition) 14.7. A Faster Way to Remove Files Interactively The rm -i command asks you about each file, separately. The method in this article can give you the safety without the hassle of typing y as much. Another approach, which I recommend, is that you create a new script or alias, and use that alias whenever you delete files. Call the alias del or Rm, for instance. This way, if you ever execute your special delete command when it doesn't exist, no harm is done -- you just get an error. If you get into this habit, you can start making your delete script smarter. Here is one that asks you about each file if there are three or fewer files specified. For more than three files, it displays them all and asks you once if you wish to delete them all: #!/bin/sh case $# in 0) echo "`basename $0`: you didn't say which file(s) to delete"; exit 1;; [123]) /bin/rm -i "$@" ;; *) echo "$*" echo do you want to delete these files\? read a case "$a" in [yY]*) /bin/rm "$@" ;; esac ;; esac -- BB 14.6. Remove Some, Leave Some14.8. Safer File Deletion in Some Directories Copyright © 2003 O'Reilly & Associates. All rights reserved.

Wyszukiwarka

Podobne podstrony:
ch14
ch14
CH14 (21)
RM ch14
ch14 (2)
ch14
ch14
ch14 (19)
CH14 (17)
ch14
BW ch14
ch14
ch14 (15)
ch14 (12)
DK2192 CH14

więcej podobnych podstron