Bash Wiki
Posts (Latest 30 updated) :
Read all
Contents:
  1. [Linux] Bash rm Uso equivalente: Remove files and directories
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[Linux] Bash rm Uso equivalente: Remove files and directories

Overview

The rm command in Bash is used to remove files and directories from the filesystem. It is a powerful command that permanently deletes the specified files, making them unrecoverable through normal means.

Usage

The basic syntax of the rm command is as follows:

rm [options] [arguments]

Common Options

  • -f: Forcefully remove files without prompting for confirmation.
  • -i: Prompt for confirmation before each file is removed.
  • -r: Recursively remove directories and their contents.
  • -v: Verbosely show which files are being removed.

Common Examples

Here are some practical examples of using the rm command:

  1. Remove a single file:
    rm filename.txt
    
  2. Remove multiple files:
    rm file1.txt file2.txt file3.txt
    
  3. Forcefully remove a file without confirmation:
    rm -f filename.txt
    
  4. Prompt for confirmation before removing a file:
    rm -i filename.txt
    
  5. Recursively remove a directory and its contents:
    rm -r directory_name
    
  6. Verbosely remove files and show the output:
    rm -v filename.txt
    

Tips

  • Always double-check the files you are about to delete, especially when using the -f option, to avoid accidental data loss.
  • Use the -i option when you’re unsure about the files you want to delete; it helps prevent mistakes.
  • Consider using rm -r with caution, as it will delete entire directories and their contents without recovery options.