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
-1
votes
2 answers

Using rm for a file in a directory

I'm new using the linux commands and I'm having a problem using the rm command in a makefile. The makefile is in the /project directory and I want to remove all the files with extension .o that are in the /project/src folder. I have tried with rm…
ezeg
  • 35
  • 5
-1
votes
2 answers

Remove all links (aliases) in a directory (tree)

I have a directory of directories which may or may not contain files, other directories or links. I want to delete all the links. Anyone know of a bash script that would let me do this quickly?
Kevin Chavez
  • 949
  • 1
  • 11
  • 27
-1
votes
2 answers

How delete all the empty files in linux irrespective of their directory using rm command

I have a lot of empty files in various sub directories of my Linux file system. How can I delete only empty files using the rm command? I'm tired of deleting by going to all the directories and finding the empty files to manually delete, so I've…
Jaiveer
  • 35
  • 2
  • 11
-1
votes
1 answer

How can I find all .txt files in specific directory, remove them and pack folder into archiv using bash script?

I have this code, which has to find all .txt files and remove them #!/bin/bash find /home/user_name -name "*.txt" | xargs rm Is it correct ? How can I archive folder after that ?
-1
votes
1 answer

Delete all files except a few using bash command

I have a directory containing lot of files in different formats. I would like to know how I can delete all files with specific format (Lets say *.dat) except a few files in a same format (e.g. A.dat and B.dat). Please advise!
Soheil
  • 193
  • 4
  • 10
-1
votes
2 answers

Deleting large no of folders in one go

I have a list of 1M folders/directory, which I need to delete on my system. What is the best possible way to do it ? I am looking for best possible solution, which will not consume lot of time, as I a have some processes which will be waiting for…
Apoorv Gupta
  • 399
  • 1
  • 4
  • 16
-1
votes
1 answer

How to remove certain pattern files except another certain pattern files from a list?

I have many file with name chr1_gene_*.raw. I would like to keep some of them. So I use following command. find . -maxdepth 1 -type f -name "*.raw" -not -name "chr1_gene_448.raw" -not -name "chr1_gene_1914.raw" -not -name "chr1_gene_2456.raw" -not…
Mike Brown
  • 331
  • 2
  • 12
-1
votes
1 answer

Unable to Delete Directories Older Than Three Days

I need to delete all sub-directories that are older than three days. The below code should work but it isn't... for i in `find ~/web/smsng/ -maxdepth 1 -type d -mtime +3 -print`; do echo -e "Deleting directory $i";rm -rf $i; done Full ls-l listing…
Aaron Perry
  • 1,021
  • 1
  • 13
  • 33
-1
votes
1 answer

unlink multiple files in a C linux program

I am trying to simulate the behavior of linux commandline command rm a1*.txt using either wildcards or regular expressions, inside a C program (linux gcc). Is there a standard way of doing that?
mousomer
  • 2,632
  • 2
  • 24
  • 25
-1
votes
3 answers

ksh - loop through directory to remove file based on part of file name

I am a new ksh developer and have a task to remove files from a directory based on two criteria. Each file name follows this pattern 1-12345-sometext.dat What I need is to be able to delete all of the .dat files with the first number equaling each…
staples
  • 424
  • 2
  • 8
  • 24
-1
votes
2 answers

ADB Root Shell, "rm -r /storage/sdcard/some/path", Permission Denied

I've got a rooted phone running, have done adb root; adb connect ; adb shell; and I am unable to rm, chmod, chown or in any way rid myself of some files under /storage/sdcard1/path/this_is_to_be_deleted/some_files.foo. I am also unable to…
justinzane
  • 1,897
  • 1
  • 26
  • 38
-1
votes
1 answer

rm: cannot remove ‘stock/δ╓¼2\036y3~.«¡Φ’: Read-only file system( from usb)

I am trying to remove a folder from USB. I tried to change the folder permission, its giving same error. `sudo chmod 777 stock/` chmod: changing permissions of ‘stock/’: Read-only file system Also I did remount usb in r/w mode. `sudo mount -o…
-1
votes
4 answers

Removing millions of files - oneliner

I want to remove millions of files in a directory and pages mentioned that the following Perl code is the fastest: perl -e 'chdir "BADnew" or die; opendir D, "."; while ($n = readdir D) { unlink $n }` However, is it also possible to do this on only…
Koen
  • 49
  • 1
  • 4
-1
votes
2 answers

Delete all files in a directory, except those listed matching specific criteria

I need to automate a clean-up of a Linux based FTP server that only holds backup files. In our "\var\DATA" directory is a collection of directories. Any directory here used for backup begins with "DEV". In each "DEVxxx*" directory are the actual…
Calab
  • 351
  • 4
  • 20
-1
votes
4 answers

Anyone ever actually tried 'rm -rf /*' in Linux?

Anyone ever actually tried rm -rf /*, or something similar, in Linux? You always hear people joke about it, but I'm curious if it actually executes, and if so, what kind of damage it actually does (not in terms of deleting disk).
kevlar1818
  • 3,055
  • 6
  • 29
  • 43