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
7
votes
5 answers

Deleting directories using single liner command

How to remove more than one directory using single command? Is it possible to do it in one liner? If yes, Please help on this. /osmf/mgmt/scheduler>ls -lrt total 22 drwx------ 2 root root 12288 Mar 26 2009 lost+found drwxr-xr-x 4…
AruM
  • 242
  • 1
  • 3
  • 9
7
votes
1 answer

Linux rm -rf * delete orders?

I thought rm removes the files in alphabetically, but clearly it's not after my executation. So, what 's the order of command rm executation?
michael_stackof
  • 223
  • 3
  • 12
7
votes
4 answers

How to remove a file whose name starts with '-'

After a mistake in a script I ended up with a file whose name starts with a dash, -: -myfile.txt I tried so far: rm -myfile.txt rm: illegal option -- m usage: rm [-f | -i] [-dPRrvW] file ... unlink file rm "-myfile.txt" rm: illegal option…
jrjc
  • 21,103
  • 9
  • 64
  • 78
6
votes
1 answer

Remove a file forcefuly as in "rm -f" or unlink a filepath from directory forcefully

I have my code as follows - #!/usr/bin/env python import time, glob, os, sys from datetime import date, timedelta try: dpath = sys.argv[1]+"/" except: print "usage: " + sys.argv[0] +" " sys.exit(1) print…
aslamplr
  • 65
  • 1
  • 2
  • 7
6
votes
3 answers

Automatically solve rm cannot remove path : device or resource busy error

I am trying to remove a directory /path/to/dir using the rm -rf command. Unfortunately I get the error rm: cannot remove '/path/to/dir/.nfsdda293a660f276ca0000000a': Device or resource busy After a little bit of research, I realized that I need to…
JejeBelfort
  • 1,593
  • 2
  • 18
  • 39
6
votes
3 answers

Why is shutil.rmtree() so slow?

I went to check how to remove a directory in Python, and was led to use shutil.rmtree(). It's speed surprised me, as compared to what I'd expect from a rm --recursive. Are there faster alternatives, short of using subprocess module?
tshepang
  • 12,111
  • 21
  • 91
  • 136
6
votes
1 answer

Why does the rm command not remove the file?

When i today accessed my Ubuntu 16.04 server and wanted to remove the file "test2" it was simply not deleted! I have used rm test2 as well as rm -f test2 but it still did not delete it as you can read here: root@icinga:~# ls basket desd.save …
user6932158
6
votes
2 answers

Delete directories older than X days

so I have looked at every single script on here regarding deleting directories older than 14 days. The Script I wrote works with files but for some reason it is not deleting the directories. So here is my scripts. #!/bin/bash find /TBD/* -mtim +1 |…
stobiewankenobi
  • 694
  • 1
  • 10
  • 16
6
votes
3 answers

Remove files created between certain time stamps.

Last night I had a script go a bit crazy and create a bunch of directories between 3:00 and 3:09am. Is there a quick one liner that will hunt these down and remove them for me?
user271528
6
votes
6 answers

How to delete all the files/folders from the folder except few folders?

I am trying to write maintainer scripts for debian package. Assume that I have a directory structure as…
exAres
  • 4,806
  • 16
  • 53
  • 95
6
votes
1 answer

Linux Shell: remove all HTML files in tree while leaving directory structure

I'm trying to remove all .html files from the directory generated and from all subfolders there but it needs to leave all other files and directories alone. I tried going through folder by folder and running rm *.html but this takes a long time as…
Joe Schmuck
  • 309
  • 3
  • 7
6
votes
3 answers

Explaining the rm ./-rf "trick"

This question states: It is amazing how many users don't know about the rm ./-rf or rm -- -rf tricks. I am afraid to try these, but curious as to what they do. They are also very difficult to search... Can someone enlighten me?
Chris Cooper
  • 17,276
  • 9
  • 52
  • 70
6
votes
1 answer

Using rm * (wildcard) in envoy: No such file or directory

I'm using Python and Envoy. I need to delete all files in a directory. Apart from some files, the directory is empty. In a terminal this would be: rm /tmp/my_silly_directory/* Common sense dictates that in envoy, this translates into: r =…
Jouke Waleson
  • 517
  • 1
  • 3
  • 14
5
votes
4 answers

How to delete all files that were recently created in a directory in linux?

I untarred something into a directory that already contained a lot of things. I wanted to untar into a separate directory instead. Now there are too many files to distinguish between. However the files that I have untarred have been created just now…
AnkurVj
  • 7,958
  • 10
  • 43
  • 55
5
votes
2 answers

hadoop fs -rm -skipTrash doesn't work

I copied some files from a directory to directory using hadoop distcp -Dmapreduce.job.queuename=adhoc /user/comverse/data/$CURRENT_DATE_NO_DASH_*/*rcr.gz /apps/hive/warehouse/arstel.db/fair_usage/fct_evkuzmin04/file_rcr/ I stopped the scipt before…
Evgenii
  • 389
  • 3
  • 7
  • 21