In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use the rm command in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The Linux common command rm command can delete one or more files or directories in a directory, or delete a directory and all its subordinate files and their subdirectories. For linked files, only the entire linked file is deleted, while the original file remains unchanged.
Rm is used to delete given files and directories
Note: be careful when using the rm command. Because once a file is deleted, it can no longer be restored. Therefore, before deleting a file, it is best to look at the contents of the file again to determine if you really want to delete it. The rm command can use the-I option, which is especially useful when deleting multiple files using file extension characters. Using this option, you will be asked to determine whether to delete it one by one. At this point, you must enter y and press enter to delete the file. If you press enter or other characters only, the file will not be deleted.
Syntax rm (option) (parameter) option-d: delete the hard connection data of the directory to be deleted directly to 0, delete the directory;-f: force the deletion of files or directories;-I: ask the user before deleting existing files or directories;-r or-R: recursive processing, processing all files in the specified directory together with subdirectories;-- preserve-root: no recursive operation on the root directory -v: displays the detailed execution of the instruction. Parameter file: specifies the list of files to be deleted. If the parameter contains a directory, you must add the-r or-R option.
Instance interactively deletes the files test and example in the current directory
Rm-i test example Remove test? n (do not delete files test) Remove example? y (delete files example) Delete all files and subdirectories in the current directory except implied files
# rm-r * it should be noted that this is very dangerous!
The rm command deletes the node_modules directory under the current directory
Find. -name 'node_modules'-type d-prune-exec rm-rf' {}'+ rm command to delete the file
# rm file 1 file 2. Rm testfile.txtrm command to delete a directory
Rm-r [directory name]-r means to recursively delete all files and directories under the directory. -f indicates forced deletion
Rm-rf testdir rm-r testdir has a confirmation prompt before the delete operation
Rm-I [file / directory]
Rm-r-I testdirrm ignores files or directories that do not exist
The-f option (LCTT: "force") forces this operation, ignoring the error prompt
Rm-f [file...] Confirm deletion only in some scenarios
Option-I ensures that only one confirmation is prompted when more than 3 files are deleted or recursively deleted (LCTT translation note: such as deleting a directory).
Rm-I file1 file2 file3 delete root directory
Of course, deleting the root directory (/) is the last thing Linux users want, which is why the default rm command does not support recursive deletions on the root directory. However, if you have to do this, you need to use the-no-preserve-root option. When this option is provided, rm will not specifically handle the root directory (/).
No more instances, the operating system has been deleted by you, are you too bad? rm displays the details of the current deletion operation.
Rm-v [file / directory] above is all the contents of the article "how to use rm commands in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.