RM command. RM is a commonly used command that removes one or more files or directories from a directory, and it can delete all files and subdirectories under a directory. For linked files, only the links are deleted and the original files remain unchanged.
RM is a dangerous command, especially when used, especially for novices, or the entire system will be destroyed in this command (e.g. / (root directory) execution RM *-RF ). So, before we execute RM , it's a good idea to check in which directory, exactly what to delete, and keep a high level of sanity in the operation.
1 . Command format:
Rm? [options]? file ... ?
2 . Command function:
Delete one or more files or directories in a directory, and RM does not delete the directory if the-r option is not used. If you use RM to delete a file, you can usually still restore the file to its original state.
3 . Command parameters:
???? -F,--force ignores nonexistent files and never gives hints.
???? -I,--interactive for interactive deletion
???? -R,-R,--recursive instructs RM to delete all directories and subdirectories listed in the parameters recursively.
? ? ???? -V,?--verbose???? Detailed display of the steps performed
???? --HELP Display this help message and exit
???? --version output version information and exit
4 . Command instance:
instance one: Delete file , the system will first ask whether to delete. ?
Command:
RM file name
Output:
Description
After entering the RM log.log command, the system asks whether to delete the file after entering Y, and does not want to delete the data n.
Example two: forcibly delete file, the system no longer prompt. ?
Command:
Rm-f Log1.log
Output:
Example three: delete any. log files, ask for confirmation before deleting them ?
Command:
Rm-i *.log
Output:
Example four: delete all files in the Test1 subdirectory and subdirectories
Command:
Rm-r test1
Output:
Example Five: RM-RF test2 Command will ? Delete all files in Test2 subdirectory and subdirectories , and without one by one confirmation
Command:
Rm?-rf?? Test2?
Output:
Example Six: delete a file that begins with the?-F?
Command:
RM---F
Output:
You can also use the following procedure:
example Seven: Customizing the Recycle Bin Feature
Command:
Myrm () {? d=/tmp/$ (date?+%y%m%d%h%m%s);? Mkdir?-p? $D;? MV? " [Email protected] "? $D? &&?echo?" Moved?to? $D? OK ";?}
Output:
Description :
The above procedure simulates the effect of the Recycle Bin, that is, when deleting a file, simply place the file in a temporary directory so that it can be recovered when needed.
Resources:
? ? ? ? ? http://codingstandards.iteye.com/blog/983531 ?
Linux command detailed-RM