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
4
votes
1 answer

Confirming rm in zsh

After discovering 'trash-put', I would like to condition myself to use it instead of 'rm' in most cases. If I just alias it that may make me feel too safe on machines without my config files though, so I came up with the following (in my…
Peter
  • 103
  • 1
  • 8
4
votes
5 answers

Argument list too long error rm command

I have a Linux based server using which i do some file manioulation and serve multiple other servers of mine. Basically this server (say server1) takes input as .mp3 file from other servers and converts to other file formats (.wav, .txt and .xml)…
Aditya
  • 2,876
  • 4
  • 34
  • 30
4
votes
2 answers

remove derived data with shell script

I'm trying to create a sh to remove the contents of Xcode's deriveddate folder. I wrote this, it goes to the desired folder, and list the content, but when I remove the # and try to delete it, than it says "**line 1:…
Ferenc Dajka
  • 1,052
  • 3
  • 17
  • 45
4
votes
3 answers

Unable to delete files with Cron

I've been working on trying to figure this out for days. Google has many answers but none of them seem to solve this problem. I was hoping someone else has had this issue and knows what to do to fix it. So the problem: I would like to delete files…
btryba
  • 41
  • 1
  • 2
4
votes
3 answers

Copying from mount share drive to local folder through script

This is my first time trying to work with Linux Scripts so this may be something obvious. Here is what I am trying to do: Remove all contents from local folder - rm /home/user/Documents/Exercise/ Copy files from a shared windows network drive - cp…
Mitchell
  • 449
  • 1
  • 5
  • 10
4
votes
3 answers

Unix delete all folders in a directory with a specific name

Hi I've got lots of folders with the name "@eaDir" all across one of my disks and I'd like to search through, find all of them and delete them and their contents. I know this is probably a combination of the find and rm command but I can't quite…
Adam
  • 532
  • 3
  • 11
  • 22
4
votes
4 answers

cronjob to remove files older than 99 days

I have to make a cronjob to remove files older than 99 days in a particular directory but I'm not sure the file names were made by trustworthy Linux users. I must expect special characters, spaces, slash characters, and others. Here is what I think…
user1469220
  • 41
  • 1
  • 1
  • 2
4
votes
1 answer

Using find to delete all files with a given name except the one with a given extension

I want to delete all files in a directory with a given name, except for one with a given extension. I.e. we have a directory with: foo.txt foo.exe foo.jpg foo.png foo.something foo.somethingelse bar.jpg bar.exe I want to get rid of foo.txt foo.jpg…
Jim Bo
  • 657
  • 3
  • 9
  • 16
3
votes
1 answer

How to use rimraf from cli to delete build folder but not remove the "build" folder itself

I want to delete the build folder for my repo. All contents inside it. But I need to keep the build folder. Essentially clean everything inside the folder but remove it. Currently I am using "rimraf build" in package.json scripts. But it removes the…
Sahil Ali
  • 172
  • 3
  • 15
3
votes
1 answer

How to efficiently delete a long list/array of files and dirs in perl

This is how I currently delete files and directories recursively foreach my $row(keys %$rows) { my $md5 = $rows->{$row}->{'md5'}; my $path = "/some/path/jpg/".substr( $md5, 0, 3 )."/$md5"; `rm -rf $path`; print "removed -…
Alex
  • 407
  • 4
  • 11
3
votes
0 answers

Can't rm -R directory MacOS Catalina

I deleted a system directory because Carbon Copy Cloner was unable to back it up and suggested replacing it. After deleting and restarting it was rebuilt by the system. However I could not delete the directory from the trash using standard methods…
John
  • 469
  • 1
  • 4
  • 17
3
votes
1 answer

"rm: cannot remove 'wslServer.sh': No such file or directory"

In my ongoing war with WSL2/VSCODE I'm trying to completely remove the .vscode-insiders directory from my machine. rm -rf wont work, neither will delete from windows. Anyone know How I can destroy this thing? I'm trying to get a dev environment set…
Meelos
  • 31
  • 2
3
votes
4 answers

Is there any difference between rm -r and rm -R?

Title is Description. I just wonder there is any difference between rm -r and rm -R. Linux man description is seemed like they are totally same(and one more, --recursive), but many people use -r and -R like they aren't same. So I want to know…
Aiden Yeomin Nam
  • 315
  • 5
  • 16
3
votes
1 answer

Cannot remove symbolic link to directory

I have a directory reference in my Downloads directory that contains a symbolic link (created with ln -s) to another directory. I get conflicting error message when trying to remove the symlink: rm returns "Is a directory" rmdir returns "Not a…
Tom Kelly
  • 1,458
  • 17
  • 25
3
votes
1 answer

TypeScript node server setup. How to remove all *.d.ts files in dist folder?

When I deploy my server I got errors server_1 | (node:9) UnhandledPromiseRejectionWarning: /usr/app/packages/server/dist/modules/listing/create/resolvers.d.ts:1 server_1 | (function (exports, require, module, __filename, __dirname) { import {…
Yegor
  • 3,652
  • 4
  • 22
  • 44