rm is the command to remove files

learn more… | top users | synonyms

1
vote
3answers
141 views

Removing a directory that has no files in it

I recently created a username and a group called gamesForAdmin. Since then I deleted it and the folder I made for it is still there: drwxr-xr-x 5 root root 4096 Jul 4 11:28 . drwxr-xr-x ...
2
votes
2answers
44 views

Remove files and directories even if not empty, except some directories

I am trying to remove all contents of a directory with some exclusions. I'm currently using this: find . -type f | grep -vZf ../../exclude.file | xargs rm -rf The exclude.file contains: *log* ...
1
vote
2answers
54 views

du cannot access file - No such file or directory error

I have lots of subfolders inside a particular folder which in turn contains lots of smaller files. They are created programmatically and so I do not know how many of them are there inside. I decided ...
3
votes
1answer
39 views

Is there a single '03 registered UNIX which can't do rm — -foo at this point?

I'm trying to dispel this uncertainty I have about the use of the double-dash (two hyphens, --) as an end of options delimiter(as opposed to a long option prefix). It's possible some confusion arose ...
5
votes
1answer
120 views

Give user permission to rm without password or sudo

I'm trying to give the ubuntu user on my machine the ability to rm folders and files (mainly in the /www/ folder) without the need to invoke a password or the need to use sudo. I've been following ...
4
votes
2answers
110 views

“no such file or directory” message when deleting a file that exists on NTFS

I have a directory with images. Suddenly I found out that there's a new image with a new name. The image content is similar to another image in another directory but with a different name. I didn't ...
1
vote
1answer
43 views

Minimum file permissions to delete a file [duplicate]

To delete a file in Linux: What minimal permissions do we need to set on it? What minimal permissions do we need to set on its parent directory?
3
votes
1answer
216 views

Cron job to delete files older than 3 days

I need to remove files older than 3 days with a cron job in 3 different directories. (these 3 directories are children of a parent directory /a/b/c/1 & /a/b/c/2 & /a/b/c/3) Can this be done ...
2
votes
1answer
70 views

Double rm verification in zsh

When I do a rm * in zsh, I get something like this: 2014-06-08 10:14:23 $ rm * zsh: sure you want to delete all the files in /home/assay/assay/log [yn]? y rm: remove regular file `development.log'? y ...
1
vote
3answers
43 views

How to remove all FIFO files with a shell command

I can't find a shell command to remove all the FIFO files inside a directory. In fact, for the removal of directories, the rm command offers the options -d, --dir, but for FIFOs it offers no option. ...
0
votes
1answer
407 views

Does Linux allow executing the “rm -rf / ” command? [closed]

We all know that we have to use the -rf option of rm command carefully. What I wonder is does Linux allow executing this command: rm -rf /? If so, why? This command could have disastrous ...
1
vote
1answer
61 views

Prevent active file removal on an NFS filesystem

I clear my logs using following script - find "." -mtime 1 -type f -print0 | xargs -0 rm -rf But it deletes the active files also and creates .nfs… files instead. Is there any way to prevent ...
2
votes
0answers
67 views

Why is my inotifywait loop exiting after removing some subdirectories?

i have the following bash script: #!/bin/sh dir1=/source/dir/path/ while inotifywait -qqre modify "$dir1"; do rm -r /destination/dir/path find /source/dir/path/ -name .svn -exec rm -rf '{}' \; ...
2
votes
1answer
150 views

Delete files/ folders with .nfs files

A lot of time when I delete a folder, it says cannot be deleted because of .nfs files Error - Device or resource busy How can I delete a folder ignoring these errors ( is there any flag in rm ...
4
votes
1answer
115 views

Is there a UNIX command to list all recently removed files from a system

Accidentally a rm -rf command was launched to my root directory instead of current directory. I stopped file removing by Ctrl+C but some files has already been removed. Is there a LINUX command to ...
0
votes
1answer
79 views

dd and rm -r commands

For me, the following commands do exactly the same thing: dd if=/dev/zero of=/dev/sd1 dd if=/dev/null of=/dev/sd1 rm -r /dev/sd1/* meaning, the result of their application is the same. Or least, ...
0
votes
0answers
34 views

named.run file deleted but data left on disk?

Today I had a name-server stop resolving DNS due to the /var directory being full from the named.run cache build up. I tried removing all the files using: rm -rf name* However, although running ls ...
0
votes
1answer
56 views

Delete subfolder and keeping up parent folder

I need to delete folderx which are not accessed for seven days, easily I can do it with next: find /path/folder -type d -mtime +7 |xargs rm -rf The probelm is when I have subfolder marked for ...
4
votes
5answers
421 views

logic behind deleting files where user does not have right to write [duplicate]

When I create a file with no write permissions in my home directory: $ umask 777; touch testfile $ ls -ln testfile ---------- 1 1000 1000 0 2014-03-21 16:52 testfile $ ..then I'm still easily able ...
1
vote
3answers
160 views

Delete files with same name at the end of the file

Delete files with same name at the end of the file i have a lot of files in my folder and sub directories like ajax_hostel_room_master.php.php class_hostel_registration.php.php ...
7
votes
5answers
552 views

Is there a simple way to preview the files that rm will remove?

Is there a simple way to evaluate what a given rm command will do when you do not understand it (such as not recognizing how the flags, variables, etc. interact)? While ls helps catch problems in ...
1
vote
2answers
171 views

Free disk space from a JBoss log file which is still being written to

Is there any locking on the content, imposed by the process if at all the process is using the file. We host a JBoss app server on a RHEL 6.4 OS and due to the disk space constraints we have decided ...
1
vote
0answers
35 views

Most efficient way of purging of 10TB data from SAN? [duplicate]

I want to purge storage data from SAN which accumulates to 10 TB. The OS is linux. The storage is mounted as mount-points on a system for which it is visible I was recommended by a friend to use ...
0
votes
1answer
397 views

How do I delete a unfortunately named folder? [duplicate]

In an unfortunate series of events, I happened to create a folder named --bindir=. Thing is, I cannot cd to him because when I try to cd I get this message: bash: cd: --: invalid option cd: usage: cd ...
0
votes
2answers
124 views

Recursively delete all files with a given extension [duplicate]

I wan't to delete all *.o files in a directory and its sub-directories. However I get an error: sashoalm@aspire:~/.Workspace.OLD$ rm -r *.o rm: cannot remove `*.o': No such file or directory On the ...
2
votes
2answers
489 views

delete old log files except the last one (alphanumerically sorted)

I have a number of log files in the form: log.2014-02-19-10_24_22 I.e. log.YYYY-MM-DD-H24_MI_SS The date that's part of the log file's name is when the log file was first created. So at any given ...
4
votes
3answers
950 views

Delete files and directories by their names. No such file or directory

I need to delete all compiled data: directories called build, directories called obj, *.so files. I wrote a command find \( -name build -o -name obj -o -name *.so \) -exec rm -rf {} \; that ...
114
votes
5answers
21k views

I deleted /bin/rm. How do I recover it?

Just for fun, I thought I would use this command on my Raspberry PI running Raspbian: sudo rm -f /bin/rm I thought I could just reinstall coreutils: I was wrong! apt-get install --reinstall ...
-1
votes
4answers
84 views

Using 'find' to create text file, and later deleting files listed

I'm trying to use find to create a text file with the result. And then later be able to delete files, based on that list. I'm using find /volume1/video/ -iname "sample" to give me the results. How do ...
1
vote
0answers
28 views

How to recover deleted directories “/home/pi” [duplicate]

I just deleted my /home/pi directory while I was trying to remove the directory under /home/pi which was /home/pi/nmap. So, is there anyway to recover /home/pi directory as I have other important ...
1
vote
1answer
61 views

rm -f files starting with a digit

I've accidentally redirected the output of a CSV file to my directory. How can I rm only the files that start with a number, and leave the files that start with a letter intact? mymachine$ ls 71.24 ...
1
vote
1answer
56 views

rm -r * in unix [duplicate]

I am about to enter the command: rm -r * in a directory where I would like all files and directories (and their files) removed. My concern is that unix also has the ./ and the ../ directories. rm -r ...
2
votes
2answers
149 views

delete directory with special character in filename

I have these tricky directories that I can't figure out how to delete. If I run ls -ld * I get… drwxrwxr-x 7 user1 taskfmri 2048 Jan 22 15:26 857263 drwxrwx--- 4 user2 ...
4
votes
4answers
211 views

Keeping the number of files in the folder constant by deleting old files

I'm trying to create a script and run it in crontab every 5 min, so that the number of files in a folder always remain 50000. If there are more, I want the script to delete the old files. ...
1
vote
2answers
88 views

Keeping the latest two version and delete the remaining

I have a list of files (say xsl format below) in one directory. I want to keep the last two version of all files. (I can delete the remaing files) {A}_1.0.xsl {A}_2.0.xsl {A}_3.0.xsl {A}_4.1.xsl ...
2
votes
2answers
56 views

Process each line from text file and delete related files from disk

I used the find command to find several files and folders and output them to a text file like so: nohup find /oradba -name '*soapr*' 2>/dev/null >find_soapr_db40.txt & So instead of ...
3
votes
2answers
300 views

grep string from contents of file command then delete file

I have a peculiar problem I need help with. I have a large batch of .docx files where a certain number of them are junk. I know how to identify these files from the file command, as they contain the ...
0
votes
1answer
393 views

Delete all 'nohup.out' within a directory recursively

How can I delete all 'nohup.out' files within a directory recursively from my terminal? I'm using CentOS.
1
vote
3answers
59 views

Preventing deletion of system/shell aliased folders

Is there a way to prevent deletion of system/shell aliased folders? I want these commands to fail. My shell is bash. Such as: $rm -rf . $rm -rf .. $rm -rf ~ $rm -rf *
3
votes
3answers
1k views

How to delete 2 months back files in unix

Say I have below log files, AA_XX_20130719185428.log exec_xxx_cpb_20130712182453.log 13122013121327_AR_INC_DOBC_1.dprf.log 24122013_masterscript.LOG Date part contains both date and time. I want ...
4
votes
2answers
624 views

Why is rm slow?

I have been trying to use rsnapshot for making backups, but I'm finding it unusable. While it is able to diff a directory (50gb) and duplicate it (hardlinking every file) in a few minutes, and I can ...
5
votes
2answers
186 views

Delete files specified by the output of find: rm thinks argument list is too long.

When I run the following command, it gives me an error: $ rm -f `find /home/domain/imap/domain.com/*/Maildir -mtime +190 | grep -E '/cur/|/new/'` -bash: /bin/rm: Argument list too long How can I ...
1
vote
1answer
474 views

Does rm -rf * delete files recursively from the current directory or parent/root directory?

I wanted to delete files and folder recursively from a particular folder so I ran this command from that folder rm -rf * I assumed it would delete all files/directories under the current directory ...
-1
votes
3answers
1k views

How do I override rw-r--r— root/wheel for a all files in a directory?

I am trying to delete a directory on OS X. I do rm -r /path/dir but I keep getting many, many messages like this: override rw-r--r-- root/wheel for cron/migrate.php? I type y for one message, ...
8
votes
1answer
740 views

Can rm recursively remove empty directories?

In an old version of Unix, the rm command would delete directories if they were empty. From the Research Unix Eighth Edition man page for rm: "If an entry is a directory it is removed only if empty." ...
2
votes
2answers
183 views

Removed `rm` command in cygwin

Having the need to use a bash shell on a Windows computer (I'll spare you the details), I installed Cygwin, and a friend as a joke ran rm /usr/bin/rm on the terminal, and surprisingly nothing much ...
3
votes
2answers
76 views

Guess complete filename

I have some files with really long names lying around on my server and writing the complete names is kind of a pita so I'm asking if my Linux system (Debian 7) can guess the complete filename? I want ...
1
vote
3answers
149 views

AIX 'rm' command has no '-v' parameter for verbose output

AIX 'rm' command has no '-v' parameter for verbose output as stated by IBM's documentation. Normally I would run (in linux) rm -rfv <myfile> to (r)ecursively and (f)orcably delete files and ...
2
votes
3answers
122 views

Remove all files except for last file of each month

Consider a directory with MySQL backup files with timestamps as part of the filename: -rw-rw-r-- 1 ubuntu ubuntu 35856184 Nov 16 16:00 db_2013-11-16_1600.sql -rw-rw-r-- 1 ubuntu ubuntu 35856915 Nov ...
2
votes
2answers
58 views

Proper escape sequence for a non-standard file name [duplicate]

I'm trying to remove a file I made by mistake using --exclude with tar. I ended up making a tar file named --exclude=*.tar Now I want to delete it but I'd like to rename it first. How do I escape it ...