Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [rm]

rm is the command to remove files

2
votes
1answer
41 views

Stop systemd from cleaning my /tmp

Before the advent of systemd, my /tmp was cleaned when and only when I rebooted my machine. I was happy. Now systemd has changed this decades-old default so that my /tmp is cleaned every 24 hours, ...
-2
votes
0answers
42 views

delete files based on selective dates from directory

I have a directory which stores db backup files every day. Using unix shell command, I need to delete all files of older than a month, except the backup files from 1st and 15th day of the month. For ...
1
vote
2answers
42 views

Why am I getting “Directory not empty” with “rm -rf”?

I'm using macOS with rm tool from GNU coreutils (not macOS’s own rm). So I have a script where I clean up some directory like this: if [ -d "${cleanup_repo_clone_root}" ]; then echo "Cleaning up ...
6
votes
2answers
487 views

Can't remove a file with file mode bits a+rw

I have a file with the following file mode bits (a+rw): [0] mypc<johndoe>:~>sudo touch /tmp/test [0] mypc<johndoe>:~>sudo chmod a+rw /tmp/test [0] mypc<johndoe>:~>ls -l ...
0
votes
0answers
21 views

cannot permanently delete Xcode.app in trash, not even if with “sudo rm -rf” because directory is not empty?

I run on osx 10.14, and I was trying to delete and reinstall xcode. I have also tried the following in safe mode but have the exact same problems. I moved xcode.app to trash, right clicked and chose ...
0
votes
0answers
23 views

Using rm --one-file-system to only delete files on the local filesystem

I have a FUSE mount located in /media/writable, however, sometimes this FUSE mount disconnects, but some programs will still attempt to write to /media/writable. When I restart the FUSE mount service,...
2
votes
2answers
82 views

Is App: /bin/rm a Friend or Foe in OSX?

Bitdefender Antivirus for Mac keeps notifying me that it has blocked App:/bin/rm with the following message: An app you previously chose to block attempted to access your protected files again. We ...
3
votes
0answers
52 views

I can see but cannot delete a file [closed]

I am running Linux Mint.I tried to copy a file with the file manager. It looked like it hung. I can see the file in the directory with ls -l: -rwxr-xr-x 1 mike domain^users 20 Mar 1 08:57 'output (...
-1
votes
0answers
68 views

Why can't I remove some files on an external hard drive?

On my external HDD with a single NTFS filesystem, why can't I remove some files? How can I solve the problem? Detach and reattach the external HDD to my computer doesn't help, so it seems no process ...
7
votes
0answers
71 views

Strange case of truly invisible file (?) and undeletable directory on macOS [migrated]

I'm having issues deleting a directory on my macOS Mojave 10.14.3 system. The filesystem is APFS and these are the symptoms: $ rm -rf strange/ rm: strange/: Directory not empty $ sudo rm -rf ...
1
vote
1answer
31 views

remove files under specific folder

What is the diff between the following two approach ? find /calc -type f -delete find /calc -type f -exec rm -f {} + my target is to remove any jar file/s under calc folder any prefered of one of ...
1
vote
1answer
26 views

How to remove a file or folder from within the grub terminal?

I'm encountering problem with my dual-boot installation. I already experienced grub problems in the past, at that time I just deleted a folder (resulting from a faulty distrib install) in my EFI ...
12
votes
3answers
2k views

Why is “rm -r” unable to delete this folder?

I have a folder with -wx permissions called folder1 and another folder inside it called folder2 with rwx permissions. I tried to delete folder1 using this command: rm -r folder1 But I got the ...
0
votes
2answers
26 views

delete folder for all users on Mac

I'm using below command to delete folder rm -rf /Users/*/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/ The command is working only for single user. I want ...
0
votes
0answers
32 views

remove program from local terminal

I tried to remove gfortran program from the local terminal windows by: rm -rf /usr/local/bin/gfortran but always I am facing the following : override rwxrwxr-x root/wheel for gfortran? I ...
1
vote
2answers
63 views

How to delete corrupted directory on Linux

I have a machine which has a directory that seems corrupt. The output of ls -lah is something like: ??????????? ? ? ? ? ? dir_name This used to be a valid directory in a ...
0
votes
3answers
54 views

How to escape parenthesis in bash rmdir?

I have a directory that has a name like 10.2 (14C92) i want to remove using rmdir -rf (to include their content). I do know how to pass a space with \ but I got the result: -bash: syntax error near ...
4
votes
0answers
51 views

Deleting non-empty directory without w permission while having w permission in parent directory

Here's the situation: dir1/dir2/file.txt permissions: drwxrwxrwx 4 me group 4.0K Jan 11 17:53 dir1 drwxr-xr-x 4 other_guy group 4.0K Jan 11 17:48 dir2 -rw-r--r-- 1 other_guy group 158 Jan 11 17:...
6
votes
5answers
682 views

How to delete all directories in a directory older than 2 weeks except the latest one that match a file pattern?

I have the following path: /dir1/dir2/ In this path I have the following directories containing various (not relevant) application detrius: follower1234 1-Dec-2018 follower3456 2-Dec-2018 ...
0
votes
2answers
57 views

how to delete files in folder with thousands of files [duplicate]

in the folder cd /var/log/hive I guess we have thundered of log files I say that because if I do under this folder ls -l then its stuck and only CNTRL C , will exit so I cant to vew all ...
0
votes
1answer
166 views

What are the differences between rm and '-delete' in find? [duplicate]

We want to delete the files under /tmp that are older than 100 minutes. What is the difference between: find /tmp -type f -mmin +100 -exec rm {} \; and: find /tmp -type f -mmin +100 -exec -delete ...
1
vote
1answer
36 views

Remove files in linux with different folder files to delete in a folder as particular folder

I want to remove multiple (all) files with different suffixes (.log,.bin) in a particular directory (/home/username) in a one-line command. How could I do that?
-1
votes
3answers
103 views

How to prevent “rm -rf ~” from being executed by mistake?

Is there any way to completely prevent this command from being executed, by mistake, in the terminal? I know that bash, for instance, has aliases. Is there a way to use them?
0
votes
1answer
39 views

What is the actual sequence of steps during rm -Rf on a very large folder?

Let's say I run rm -Rf on a very large folder with many files and folders of different size, user permissions etc. I would like to know, does the rm command first accumulate the list of files to ...
10
votes
1answer
898 views

Debian: cannot remove symlink in /sys/: operation not permitted

I ran some commands without completely understanding them while trying to get screen brightness working and now I'm stuck with a nasty symlink in '/sys/class/backlight/asus_laptop' that I am trying to ...
3
votes
1answer
340 views

rm to remove a dir, any symlinks, AND symlink destinations? [duplicate]

I have two directories: /all/origins/ & /all/links/. Everything in links/ points individually to something in origins/, but not everything in origins/ is linked in links/. (Squares, rectangles &...
1
vote
1answer
139 views

unlink delete files which are not links [duplicate]

I created a hard link $ ln hours.sh hours_link test it $ ls -l hours* -rw-r--r-- 2 me staff 653 Apr 12 2018 hours.sh -rw-r--r-- 2 me staff 653 Apr 12 2018 hours_link remove it with unlink $ ...
1
vote
4answers
258 views

double check remove on a wildcard

I accidentally removed a bunch of files I wasn't supposed to. I would like to implement some kind of safety net in the future to protect my files. I was hoping that any time I type rm * into the ...
0
votes
2answers
41 views

delete then rename: same filenames different extensions

I have a directory containing thousands of files, each file has a duplicate. An example: file1.txt file1.jpg.txt file2.txt file2.jpg.txt I want to delete all *.txt files, and leave the *.jpg.txt ...
1
vote
3answers
49 views

Remove files + files from subdirectories in Directory

I would like to remove all files from a directory /data which includes 8 other sub directories. Is there a command which will recursively clear all subdirectories but not remove the actual folders?
0
votes
1answer
98 views

Empty trash in ubuntu

I'm trying to empty my trash using the UI but it doesn't work. i tried to use this command rm -rf ~/.local/share/Trash/* but it does not success with messages like rm: cannot remove 'file.txt': Read-...
6
votes
3answers
793 views

Remove files that start with but don't contain

I'm trying to remove a lot of files at once but need to be specific as to not remove any of the files I actually need. I have a ton of corrupt files that start master- but there are valid files that ...
0
votes
2answers
35 views

Delete directories if they do not have newer files

I want to delete directories only if they have not changed in the last N days. And by changed I mean contain any files that are more recent than N. I constructed something similar / found this but ...
7
votes
5answers
784 views

Remove files which not named “today.md” [duplicate]

I have the a series of markdown files in the working directory: $ ls *.md csv_reader.md egrep.md find.md found_pdfs.md osPathSep_help.md readme.md smtplib_help.md today.md I want to remove ...
1
vote
0answers
38 views

removing directory [closed]

After motherboard replacement and system upgrade to Mojave my Mac was restored from backup including some macports codes in /opt . Since macports would not work properly I had to rename /opt/local to /...
0
votes
1answer
110 views

How to delete all directories inside a directory except for files, (safely)?

Environment System: Linux Mint 19 Cinnamon. Shell: Bash version 4.4.19(1). Problem Along with hundreds of testing scenarios, I must have created countless of temporary installation directories ...
2
votes
3answers
356 views

Delete identical files saved as output in a log

I have three files in two folders. The files are named, a.txt, b.txt and c.txt were located in A and B folders. I have used an app Full File Mini Comparer which compares the folder and saves to log to ...
0
votes
2answers
356 views

Using regular expression for rm and ls

QUESTION: What is happening here and how do I fix it? PROBLEM: When I do: $ls | grep -P "file[1-9]{3}.txt|file[1-9]{2}.txt" I get: file11.txt file12.txt file13.txt file14.txt file15.txt file16....
-4
votes
3answers
60 views

What does this command mean? (IO redirection question) [closed]

I am trying to figure out what this command is doing: rm OUTPUT/* >> log_${ENV} 2>&1
2
votes
2answers
84 views

Error in deleting files or directories older than 1 day

I am able to delete files or directories older than 1 day using below command find /u01/Release/* -mtime +1 -exec rm -r {} \; but why I am getting error in the output of this command: ls -lrt ...
-1
votes
1answer
49 views

Removing files containing, only, one row? [duplicate]

I have large number of csv files saved within a folder. I would like to, only, delete the csv files that contains one row, how can I do that?
1
vote
1answer
721 views

Is “find /var/log -type f -delete” safe on Debian 9?

I never view or care about files in /var/log/ and want to avoid logrotate wasting my system resources (CPU, RAM, I/O, etc.). Are any regular files in /var/log/ necessary for some core Debian program (...
0
votes
0answers
44 views

How to delete a git repo with submodule from NTFS partition and then git clone it with submodule initialized?

I tried setting my 2 TB hard drive partition into a NTFS file system, per an answer to an earlier question of mine. I moved a heap of my git repos onto it. Some of my repos have submodules, and ...
3
votes
2answers
514 views

How to delete files created between two times?

I have a folder where I backup my databases to and I want to delete all backups created between 11 am and 3 pm and it doesn't matter what day it is -- this is the catch! I found this command to be ...
2
votes
2answers
199 views

How to remove every file and folder recursively except for a few specific folders?

Having the Busybox ash shell at hand, I wish to cleanup the /opt folder. Cleanup means to remove every file and folder recursively except for a few exclusion paths that need to be left untouched. ...
0
votes
2answers
429 views

Why does my 'rm' command work fine in terminal on my mac but not from shell script?

I have a directory whose name contains spaces. I need to remove the contents of this particular directory. I am escaping spaces in the directory name with \ before removing the contents. The rm ...
1
vote
1answer
299 views

Yet another `rm: cannot remove 'file': Permission denied`

I want to remove the .html file from the /home/user1/html/ directory. I have tried nearly all of the solutions posted on a myriad of other web sites. Nothing is working. user1@comp1:~/html$ sudo rm ...
0
votes
1answer
261 views

How to remove parent directory without deleting sub folders?

For Example, I have 5 directories inside parent directory, I want to delete parent directory without deleting 5 subdirectories. As of now am doing with below code, mv parentFolder/* parentFolder/.....
3
votes
2answers
55 views

Delete .pdf files only if .xlsx files in directory have same filename?

I have folders with hundreds of pdf and xls(x) files that were mass exported from legal e-discovery systems. The filenames in these exports correspond to bates # such as ABCD_00000001.pdf, ...
0
votes
3answers
312 views

Delete the oldest files in folder if combined size of folder is more than 10G

The following syntax will remove the files under hive folder: /usr/bin/find /var/log/hive -type f -print -delete I am trying to do the following: Remove the oldest files under /var/log/hive only if ...