linux - prompt list of files before execution of rm -


i started using "sudo rm -r" delete files/directories. put alias of rm.

i know doing , quite experience linux user.

however, when press "enter", before execution of rm, list of files show on screen , prompt @ end ok deletion of files.

options -i -i -v not want. want 1 prompt printed files on screen.

thank you.

## # double-check files delete. delcheck() {   printf 'here %d files said wanted delete:\n' "$#"   printf '"%s"\n' "$@"   read -p 'do want delete them? [y/n] ' doit   case "$doit" in     [yy]) rm "$@";;     *) printf 'no files deleted\n';;   esac } 

this shell function (when used properly) want. however, if load function in current shell try use sudo, won't expect because sudo creates separate shell. you'd need make shell script…

#!/bin/bash  … same code above …  # script create function , execute it. # it's lazy, functions nice. delcheck "$@" 

…then make sure sudo can access it. put in place in sudo execution path (depending on sudo configuration.) if really want execute precisely sudo rm -r * still need name script rm, (which in opinion dangerous) , make sure path before /bin in path. (also dangerous). there go.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -