ADVERTISEMENT

Linux Commands ❯ rm

rm

Remove (unlink) the FILE(s).
syntax:

rm [OPTION]... FILE...
  • rm -d *
    deletes all the empty directories in the current directory
  • rm -d -f *
    deletes all the empty directories in the current directory without any prompting
  • rm -f *
    deletes all the files in the current directory without any prompt
  • rm -f my_file{1..5}
    delete files my_file1, my_file2, my_file3, my_file4 and my_file5 without any prompting
  • rm -i *
    attempts to interactively remove all the files in the current directory.each file will be prompted and an affirmative response deletes the file.
  • rm -I *
    deletes all the files in the current directory without any prompting if the number of files are 3 or less. one time prompting to confirm if the files are more than 3.
  • rm -r my_dir
    deletes all the contents of my_dir and directory itself recursively.each entry will be prompted before deletion
  • rm -R my_dir
    deletes all the contents of my_dir and directory itself recursively.each entry will be prompted before deletion.
  • rm -R -f my_dir
    deletes all the contents of my_dir and directory itself recursively without any prompting
  • rm -r -f my_dir
    deletes all the contents of my_dir and directory itself recursively without any prompting.
  • rm -v -f *
    deletes all the files in the current directory without any prompting. the v option makes to display the file names that has been deleted