rm is the command to remove files

learn more… | top users | synonyms

-2
votes
3answers
49 views

Delete subdirectory folder while saving contents

Lets say I have the directory /Users/admin/Documents/Folder1/file1.txt and would like to delete Folder1 without also deleting file1.txt. In the end it should look like ...
6
votes
2answers
128 views

How can I delete a file named “--append”? [duplicate]

By mistake I have created a file named : --append. How do I delete it? Simply entering the usual command, rm -f --append, doesn't work.
0
votes
2answers
34 views

Interactively remove files in loop with standard input redirection

I need to interactively (i.e. rm -i) remove files stored in variable $to_remove (one path per line). Unfortunately my code doesn't work because standard input is already used by redirection ...
0
votes
1answer
39 views

Count deleted files with interactive rm (rm -i)

I want to count number of interactively removed files and directories: for f in /tmp/mydir/* ; do rm -ir "$f" done How to do it in most concise/elegant way? Example: abc@def:/tmp/mydir$ tree ...
0
votes
2answers
31 views

rm refuses to remove folder! (nothing to do with the -R option)

I'm using Ubuntu on my personal laptop, and on my system, whenever I use rm on a file, it is gone. for good. The problem is on my university server. I am trying to delete a folder: environment/tests ...
19
votes
3answers
490 views

The precedence of command options?

I know that rm -f file1 will forcefully remove file1 without prompting me. I also know that rm -i file1 will first prompt me before removing file1 Now if you execute rm -if file1, this will also ...
1
vote
1answer
34 views

File/directory not being deleted?

Please see the screenshot. The image on the left says existing x installation found at /opt/x The image on the right shows the terminal where I attempt to delete the same directory. The terminal on ...
0
votes
2answers
74 views

Recursive rm doesn't work for me

Suppose, we have the following files in a directory: test.txt test.txt~ /subdir test1.txt test1.txt~ When I run rm -r ./*.*~ inside top dir only test.txt~ is removed. Why doesn't it perform ...
3
votes
3answers
104 views

Bulk remove a large directory on a ZFS without traversing it recursively

I want to remove a directory that has large amounts of data on it. This is my backup array, which is a ZFS filesystem, linear span, single pool. The data is in this pool called san, mounted on /san ...
4
votes
4answers
272 views

Remove a directory from inside using the command line interface [duplicate]

Imaging the next simple file structure within the /home/user/ directory: /home/user |--dir0 |--dir1 |--file1 My current directory is 'dir1' and I remove the ...
-2
votes
1answer
60 views

how to delete swarm of ._ files using commandline

I have these files in MAC which have weird ._ character before filenames/folders. Which I want to delete in one shot. Is there a way to do it in commandline? eg. ._js ._css ._image if I go into ...
-6
votes
1answer
59 views

Delete Huge file in linux

I would like to delete a large file in my server. It's very large nearly more than TB's. What is the best way to delete that huge file ???
4
votes
1answer
129 views

Undeletable directory

Everything I've tried (always with superuser privileges) has failed: # rm -rf /path/to/undeletable rm: cannot remove ‘/path/to/undeletable’: Is a directory # rmdir /path/to/undeletable rmdir: failed ...
3
votes
2answers
131 views

rm not deleting file, thinks its a directory

I have a hard drive with windows loaded on it hooked up to my Linux machine for backing up some of the information. I want to delete one of the 'temporary internet files' folders and it deleted all ...
2
votes
2answers
96 views

How to remove a file that can be seen but no program can seem to touch?

I'm trying to remove some obsolete backups, and deep inside one I've found a file 'cifs3bee' that I can find no way of removing. (And since I can't remove it, it's preventing the removal of the entire ...
4
votes
2answers
94 views

sudo rm -rf returns “cannot remove directory” on empty directory owned by root

I have a directory on my Debian system. The directory is: root@debian:/3/20150626# stat 00 File: `00' Size: 6 Blocks: 0 IO Block: 4096 directory Device: fe00h/65024d Inode: ...
0
votes
1answer
52 views

“find” function still print files I've already removed

I've removed some directories and files inside them using sudo rm and sudo rmdir, but when I execute sudo find /*/*/ng* the files I've previously deleted are still showing up, anybody know why and ...
3
votes
2answers
135 views

File deletion under special conditions, recursively if possible

I am looking for a unix command sequence, which is able to perform a quite complex, conditional deleting action. All files with the extensions "[NAME].cut" and "[NAME].cut.bak" shall be deleted, IF ...
2
votes
3answers
115 views

Delete several sequential file names, but ignore part of the first

Sometimes, my scripts get trapped in infinite loops. When the loop creates new files, things get messy. I currently have this file name format: Task.4883.store.log where 4883 is a counter. I ...
1
vote
1answer
324 views

delete multiple remote files with the FTP command

Right now we have a script that uses the FTP mget command to download all the files in a specific location. After after verifying the files have successfully downloaded we run a ftp delete command ...
5
votes
3answers
254 views

How does Linux format itself while running? [duplicate]

When you run sudo rm -rf --no-preserve-root / Your system will delete every file, one by one. However, this also includes running processes and the operating system itself, eventually deleting rm. ...
0
votes
1answer
82 views

How many files can rm delete at once? [duplicate]

One of my friends wanted to have more logs in the /var/log/ directory, and after some time of using the system, he tried to access the folder and list it, but instead he got the following error: ...
4
votes
2answers
369 views

Where is the trash can for root partition?

I use trash-put to trash files from command line. Recently, I had aliased my rm command to trash-put so that I don't accidentally delete something important. However, what happened now was that I ...
1
vote
2answers
61 views

How to remove all files in a directory except hidden ones?

I'm cleaning an output directory before I put things in it. I want to track the output directory in git with a .gitkeep file, but this keeps on getting deleted with my rm -rf "$OUT_DIR" line in a ...
1
vote
1answer
45 views

How to put “rm -i” in an iteration?

echo "$MOUNTPOINTLIST" | while read onelinefortouch; do touch "${onelinefortouch}testfileforwrite"; done echo "$MOUNTPOINTLIST" | while read onelineforrm; do rm -i "${onelineforrm}testfileforwrite"; ...
6
votes
5answers
1k views

Deleting files with spaces in their names

I am trying to delete all the files with a space in their names. I am using following command. But it is giving me an error Command : ls | egrep '. ' | xargs rm Here if I am using only ls | egrep '. ...
-1
votes
1answer
41 views

How to delete a file that starts with a -? [duplicate]

I accidentally created a file when I meant to pass an option. Now I have a file named: -myfile that I can not delete with rm -myfile $ touch hi > -myfile $ rm -myfile rm: invalid option -- 'm' ...
2
votes
1answer
57 views

What happens step by step when using “rm -rf directory”? [duplicate]

Let's assume that I have 150 GB of data in a directory and I have accidentally run this command for a directory. Suddenly I realised, I should not put "/" in the beginning of directory and I ...
0
votes
1answer
102 views

Remove files newer than X day and hour

I want to remove files, more specifically, symbolic links of /usr/include that are newer than 2 JUN 22:27 How can I do this?
2
votes
1answer
47 views

How to delete stubborn directory?

I'm having issues with dropbox so I'd like to uninstall and reinstall it. To do so I need to remove ~/.dropbox-dist but no matter what I do it won't budge. If I run ls -l I get: drwxr-xr-x 3 user ...
3
votes
1answer
61 views

Deleting ghost files with non-ASCII characters

I have some weird files and folders in my trash on Mac OS X. After I "empty" the trash, the files still remain. I attempted to manually delete the files: $ cd ...
3
votes
2answers
394 views

Why can't I delete this file as root?

I have directory exam with 2 files in it. I need to delete files but permission is denied. Even ![rm -rf][1] command can't delete these files. I logged in as a root user.
20
votes
4answers
2k views

How can I delete a file named “>”?

I was running a Python script that malfunctioned and used sudo to create a file named >. How can I get rid of this file? Of course, when I try sudo rm >, I get the error bash: syntax error ...
1
vote
2answers
113 views

Why can't root delete a file?

On a samba share, I have a .DS_Store file on a SMB network share that is causing havoc. Even as root, I can not delete or chmod it. -rwx------ 1 bob acme\Domain Users 6148 Apr 24 09:11 ...
2
votes
1answer
275 views

rm -rf: cannot remove `/opt/jetty': Directory not empty

I have a script using the following command to remove a folder: ssh -q root@hostname sh -c 'rm -rf /opt/jetty/' Most of the times it works fine, but occasionally I get this message: rm: cannot ...
0
votes
4answers
301 views

delete all .swp file using rm command

I am trying to find and delete all .swp files in my current directory. I was using below command: rm -i `find . | grep .swp$` But everytime it is giving me this error: rm: missing operand Try `rm ...
1
vote
1answer
453 views

Why can't I remove the empty directory with username www-data? [duplicate]

The test is a directory which contains nothing, an empty directory. root@localhost:~# ls -l /home drwxrwxrwx 2 www-data www-data 4096 Apr 26 17:50 test root@localhost:~# ls -l /home/test ...
0
votes
1answer
73 views

find all directories (except `encoded`) in the working dir then delete all of them

I am trying to test this scenario, I have these files /encoded encode <~~~ a bash script /dir1 /dir2 .../dir2-sub test.meta what I wish is, for find to search for all directories in our current ...
0
votes
1answer
246 views

Cannot (force) remove directory in Docker build

With this Dockerfile: FROM php:5.4-fpm RUN apt-get -qqy update \ && apt-get -qqy install git \ libcurl4-gnutls-dev \ libmcrypt-dev \ ...
2
votes
2answers
4k views

Delete files older than X days +

I have found the command to delete files older than 5 days in a folder find /path/to/files* -mtime +5 -exec rm {} \; But how do I also do this for subdirectories in that folder?
1
vote
2answers
208 views

Why doesn't “rm -rf ./” delete anything?

The command rm -rf ./ does not do anything in a directory full of sub directories and files. Why so? Isn't -r supposed to go recursive? To add more confusion, it even prints an error message ...
0
votes
1answer
89 views

tar unused files then delete them

I have folder with subfolders and sessions logs. I need some commands or script to tar this folder without usage files and then delete it. I have this construction, but I'm not sure if this leave ...
0
votes
1answer
53 views

If “rm dir -r” has removed just partial content of dir/dir1/, has it not removed anything in dir/dir2/? [duplicate]

If rm dir -r has removed just partial content of dir/dir1/ (and I cancelled rm), has it not removed anything in dir/dir2/ if dir/dir2/ still exists and contains something? My OS is Ubuntu 14.04 and ...
0
votes
0answers
25 views

Cancel removing a directory, and want to find out what have been removed

I was removing a directory by rm -r mydir and cancelled it in the middle. How can I find out what have been removed under the directory? Does remove a content of a directory change the timestamp of ...
1
vote
0answers
53 views

Why is rm -r the same as rm -R?

If you look in the rm man page you see that rm -r, rm -R, and rm --recursive are all the same. -r, -R, --recursive remove directories and their contents recursively When using options, I'm ...
4
votes
1answer
57 views

Recovering data written to file that moved

I have a Python daemon running on CentOS that opens a file at the beginning of a session, and keeps writing to it. A cronjob however, gzipped the file that was being written to, and so the file moved ...
1
vote
2answers
73 views

how to delete file that start with “-” [duplicate]

I try to delete this file on my solaris machine rm "-Insi" rm: illegal option -- I rm: illegal option -- n rm: illegal option -- s I also try this rm "\-Insi" -Insi: No such file or directory ...
4
votes
4answers
1k views

Why does `rm -f !(/var/www/wp)` leave files behind in /var/www?

Why does the rm -f !(/var/www/wp) command have no effect? I want to remove all the files in /var/www, except for the /var/www/wp directory, which should remain. root@born:~# ls /var/www ...
0
votes
2answers
77 views

How to delete the whole root with rm rf and shred together?

My task is simple: I need to able to delete the whole root which i can do with rm-rf ./* but the problem here is HFS recovery can get back the data since it is not actually deleted from disk if i ...
1
vote
0answers
129 views

rm: Directory resources is not empty

I'm getting this kind of error when i'm deleting file on my AIX machine. Getting same error for rmdir. venky-19:[/hm/dev/application/backup/ear/] # rm -rf resources rm: Directory ...