rm is the command to remove files

learn more… | top users | synonyms

1
vote
2answers
23 views

Deleting all files except folders within directory

I am still pretty new to terminal based commands but while I was doing a rsync command between remote and local, I have accidentally 'copied' the files to the wrong place (Eg. /serA/items) instead of ...
1
vote
2answers
88 views

How to remove a file with two words separated by a space in the shell? [duplicate]

I made a text file called hello world in my home directory. Via the shell I am trying to remove it with the rm command. However, when I execute rm hello world the shell thinks that I am trying to ...
-1
votes
1answer
30 views

Remove files and subdirectories of particular folder

I need to remove files and sub-directories in a particular folder but not that folder itself. I am using below command: find . -type d -depth -mtime +7 -exec rm -rf {} \; But it throws following ...
1
vote
1answer
24 views

Detecting file size and do operation conditionally

In my main_dir, I have a lot of sub-folders say DFT1 to DFT150, and in each directory, there is a file named OSZICAR. However, some of this would have file size 0. So I would like to have a script, ...
2
votes
3answers
75 views

How to delete that directory?

I have a directory, that I cannot delete with rmdir. I get always a permission denied error. But when list the directory (with ls -l) I get this: drwxrwxrwx 2 user user 4096 Aug 28 09:34 directory ...
37
votes
2answers
3k views

why is rm allowed to delete a file under ownership of a different user?

From the post Why can rm remove read-only files? I understand that rm just needs write permission on directory to remove the file. But I find it hard to digest the behaviour where we can easily delete ...
-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
129 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
35 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
41 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
491 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
76 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
108 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
276 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
71 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
136 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
98 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
96 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
54 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
140 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
117 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
387 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
256 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
86 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
377 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
65 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
46 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
47 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
109 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
62 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
438 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
115 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
279 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
326 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
479 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
75 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
261 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
224 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
90 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
26 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 ...