Questions tagged [rm]

rm is a basic UNIX command used to remove files, directories, and other items from the filesystem.

rm is a basic UNIX command used to remove files, directories, and other items from the filesystem.

Options:

-f force
-r, -R or --recursive

Examples

rm -rf /some/dir #removes all files and dirs recursively from this point

References

534 questions
13
votes
4 answers

Trying to remove my .git folder and 'rm -r .git --force' is not working

rm -r .git rm -r .git --force I get the following and there seems to be a never ending supply after I enter 'yes' and move to the next. override r--r--r-- redacted/staff for .git/objects/95/90087aa4b351e278e6e53ff6240045ab2db6d1?
seamus
  • 2,681
  • 7
  • 26
  • 49
13
votes
3 answers

Difference between 'find -delete' and 'rm -rf'?

I want to delete files from a specific directory recursively. So, I have used find . -wholename "*.txt" -delete We can also delete the files using rm -rf *.txt What is the difference between deletion of file using rm and find ??
Aashish P
  • 1,894
  • 5
  • 22
  • 36
12
votes
5 answers

Recursively unzip files and then delete original file, leaving unzipped files in place from shell

I've so far figured out how to use find to recursively unzip all the files: find . -depth -name `*.zip` -exec /usr/bin/unzip -n {} \; But, I can't figure out how to remove the zip files one at a time after the extraction. Adding rm *.zip in an -a…
Ben
  • 123
  • 1
  • 1
  • 4
12
votes
4 answers

How to correct docker in makefile which requires at least 1 argument for remove all containers command

The docker command "docker container rm $(docker ps -aq) -f" works fine from the command line. However, when I try to run it from a makefile using the following target ("remove_all_containers")... remove_all_containers: docker container rm…
Information Technology
  • 2,243
  • 3
  • 30
  • 46
11
votes
1 answer

PHP can't unlink file after fclose

After my script finishes I can delete the file, but while it's running I can't touch it, even after an fclose(). Here is the code I'm trying to use: $Files = glob("$_SERVER[DOCUMENT_ROOT]/files/*.csv"); $File = fopen($Files[0], "r"); …
Brian Leishman
  • 8,155
  • 11
  • 57
  • 93
11
votes
3 answers

Removing files interactively with find and xargs

I'm trying to pipe some files from the find command to the interactive remove command, so that I can double check the files I'm removing, but I've run into some trouble. find -name '#*#' -print0 | xargs -0 rm -i I thought the above would work, but…
CopOnTheRun
  • 1,117
  • 2
  • 12
  • 21
10
votes
5 answers

Bash script to remove all files and directories except specific ones

I am trying to write a very simple Bash shell script that will cd in a specific directory, it will remove all files and directories except some few selected ones and then cd back to the original dir. My code is: #!/bin/bash cd…
mariotoss
  • 414
  • 3
  • 7
  • 17
10
votes
3 answers

Delete a file in linux that contains double dash

Possible Duplicate: Unable to remove a special named files in terminal I feel silly asking, but how can I delete a file in linux named --preserve-permissions? I tried: rm "--preserve-permissions" and rm "\-\-preserve-permissions" Neither…
Justin
  • 42,716
  • 77
  • 201
  • 296
9
votes
3 answers

Unable to recover a file in Git

Possible Duplicate: Restore a deleted file in a Git repo I have two branches in my Git, master and newFeature. At the branch newFeature, I removed the fileA physically first in terminal and then in Git by git rm fileA Subsequently, I run git add…
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
9
votes
4 answers

Bash: What's the difference between "rm -d" and "rm -R"?

Questions What is the difference between the rm -d and rm -R commands in Bash? Which one should I use? Details According to the man page for the rm command: rm -d attempts to remove directories as well as other types of files. rm -R…
caleb531
  • 4,111
  • 6
  • 31
  • 41
9
votes
3 answers

How do I delete folders using regex from Linux terminal

Say I have folders: img1/ img2/ How do I delete those folders using regex from Linux terminal, that matches everything starts with img?
c 2
  • 1,127
  • 3
  • 13
  • 21
8
votes
3 answers

remove files when name does NOT contain some words

I am using Linux and intend to remove some files using shell. I have some files in my folder, some filenames contain the word "good", others don't. For example: ssgood.wmv ssbad.wmv goodboy.wmv cuteboy.wmv I want to remove the files that does NOT…
DocWiki
  • 3,488
  • 10
  • 39
  • 49
8
votes
3 answers

Cannot remove .git: Directory not empty

Unable to remove .git I have a git repository, Rift, that I am trying to remove. On attempting to run rm -rf, I get the error: rm: cannot remove 'Rift/.git/objects/pack': Directory not empty. When I navigate to the bottom of the directory tree, I…
Vendetta
  • 2,078
  • 3
  • 13
  • 31
8
votes
5 answers

Is there any trivial way to 'delete by date' using ´rm'- in bash?

I noticed today (after ~8 years of happily hacking away at bash) that there is no trivial way to 'delete by date' using ´rm'. The solution is therefore to pipe stuff around a combination of commands like rm, ls, find, awk and sed. Say for example I…
Fergie
  • 5,933
  • 7
  • 38
  • 42
8
votes
1 answer

how to remove everything with rimraf except few exceptions

i’m trying to remove all .dot files, except .git and all *.js except one exception.js, but i’m failing install git clone git@github.com:iamstarkov/rimraf-test.git cd rimraf-test test npm test # it fails can anybody help me?
Vladimir Starkov
  • 19,264
  • 8
  • 60
  • 114
1 2
3
35 36