-
Notifications
You must be signed in to change notification settings - Fork 3
rmrf
Available Since Version 0.8
rm -rf
command is convenient and powerful. It lets you delete one or more files or folders. (In case of a folder, it will recursively delete everything under that folder and the folder itself) However, using it without caution may cause a disaster.
For example, say, you wanted to type rm -rf /foo/bar
, but typing in a hurry might end up like rm -rf / foo/bar
, which would possibly delete the entire file system!
Or when your intention was rm -rf "/foo bar/baz"
, but you omitted proper quoting like rm -rf /foo bar/baz
, then you would end up deleting /foo
not /foo bar
. If you happened to have /foo
, then that would possibly delete some valuable data!
rmrf
is a wrapper command for rm -rf
. It delegates jobs of deleting files/folders to rm -rf
command, but it detects possible dangers beforehand.
Its unique behaviors are:
- It will deny deleting root level files/folders
- e.g)
rmrf /foo/bar
will be aborted. - So it will keep you from mistakenly deleting root level folders.
- Basically, you can't use
rmrf
to delete any of root level files/folders, so you need to use other methods to do that, but at least it will make you stay focused when deleting critical data like root level folders.
- e.g)
- It will deny deleting
../
or./
- e.g)
rmrf ../ foo/bar
will be aborted. - e.g)
rmrf ./ foo/bar
will be aborted. - If
rmrf
sees any of../
or./
not followed by folder names, it will abort the operation. ( Operations likermrf ../foo/bar
are OK. )
- e.g)
- It will always ask your final confirmation before actually deleting files/folders
- This is for giving you a final chance to confirm you are deleting right ones.
- It will highlight names of files/folders about to delete in a different color so that they are noticeable.
- Type
y
to proceed or typen
to abort
Using rmrf
in a separate command is useful, but it also can be used in conjunction with lf or lfs or lff
Use del=
Behavior Control Variable to delete files/folders found by lf
or lfi
like so:
$ lf .js
foo.js
bar.js
$ del= lfs
lf.sh : Are you sure if you want to delete the following path? (y or n)
foo.js
bar.js
y
lf.sh : "foo.js" (file) deleted...
lf.sh : "bar.js" (file) deleted...
The operation above is the same as
del= lf .js