Questions tagged [rm]

rm is the command to remove files

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

Delete all files and folders recursively but excluding one folder [duplicate]

I have a folder structure like this: my-root-folder ├── .git ├── README.md ├── index.css ├── index.js ├── index.html ├── assets │ ├── image │ │ ├── logo.jpg │ │ ├── header.jpg i want ...
0
votes
1answer
35 views

How do I delete a folder but only keep selected files?

My folder structure is as follows: Photos | |---> 2015-08-23 | |---> IMG_0019.JPG // keep IMG_0019.JPG.json // toss IMG_0020.JPG // ...
1
vote
1answer
27 views

hiding a file from sudo rm -rf * (or skipping)

I am trying to hide one new file from a script that contains 'sudo rm -rf *' - I am wondering if I can do this without redoing the script/ if this is possible or not. I have tried the following: $ ...
0
votes
1answer
38 views

why aliases found in root users ~/.bashrc file are not used for standard users by default?

Is there any reason why aliases like alias rm='rm -i' found in the ~/.bashrc file of user root are not used by default for any other users?
0
votes
1answer
391 views

Trying to remove rm a file with ( in its name

In pythonanywhere’s bash I am trying to remove the file: rm /home/olb/Email Thu, 19 Mar 2020 18:49:16 +0000 =?UTF-8?Q?Update_from_GOV.UK_=E2=80=93_Coronavirus_(COV?= =?UTF-8?Q?ID-19)...
0
votes
0answers
10 views

get “Directory not empty” when I try to remove directory on external Tuxera NTFS drive?

try to delete some old folder (on NTFS driv - Tuxera) when use delete immediately: "is in use" i try restart but nothing changed & can't try in safe mode because of Tuxera needed try with rm -...
0
votes
1answer
21 views

Delete files in a directory that have a hyphen in the filename

On my macOS system, I have a folder with 7,000+ images, and need to delete the images that have a hyphen in the filename. I have tried the following commands without getting a response after I cd into ...
0
votes
3answers
26 views

How to remove many files of similar names?

I have many txt files, named like file1.txt file2.txt file3.txt ... file1000.txt How can I delete all these files? I am new to unix and concerned about accidentally deleting other files in my ...
2
votes
2answers
48 views

Remove all files/directories except specified ones in multiple levels

Is it possible to do the below with one line? shopt -s extglob rm -r !(folder1|file1|folder2) rm -r folder2/!(subfolder) rm -r folder2/subfolder/!(onefile) For example, something like this? rm -r !...
0
votes
1answer
21 views

Remove directory of a known file in CentOS 6

I have a database that returns a string. The string contains the location of a file. What I want to do is to remove the directory that contains that file using CentOS command. Is that possible? I know ...
0
votes
1answer
320 views

Why rm gives warning when deleting a write protected file?

I have a regular file and I changed its permission to 444. I understand that as the file is write protected, we can't modify or remove the contents of file but when I try to remove this file using rm, ...
1
vote
0answers
37 views

Why is zsh ignoring my -f switch when removing files? [duplicate]

I just moved to zsh from bash on my mac, i hope this is the right place to ask. Works great, although I've noticed that if I run rm, for example rm -rf my directory I always get a prompt asking me ...
0
votes
2answers
100 views

some files have '.' in their name, how can I delete them using the .txt file as input to the rm command

I have text files listing a lot of files that are on my linux system that have been identified as needing to be deleted. Some of these files were created on Windows and contain '1. ' or '2. ' (i.e. ...
1
vote
1answer
73 views

How to find and delete OS junk files on /var

I tried to update my "Fedora" by using Terminal. It worked great at first but after a while it said that "there is not enough space in var/". I added some more space by using Gparted and now ...
0
votes
1answer
81 views

rm with invert-match

I submitted 6490 jobs to our HPC > ls -1 split-data/*.fasta | wc -l 6490 > ls -1 split-data/*.fasta split-data/utg000001l.fasta split-data/utg000002l.fasta split-data/utg000003l.fasta split-...
3
votes
0answers
84 views

How do I know if my computer is susceptible to bricking via rm -rf?

I've heard a lot of horror stories of rm -rf / not only deleting the operating system (as expected) but also hard bricking the hardware of the system by deleting important firmware variables, ...
0
votes
0answers
51 views

rm command crashed my server

I ran the following command find /tmp/ -type f -mtime +2 -exec rm -f {} \; on my centos server in the attempt to free some space. After running this command my server crashed. I had to restore from a ...
0
votes
0answers
25 views

Lunux (Ubuntu 16.04) No permissions to delete file

root@grey2011g2:/home# chmod -R a+X admin/conf chmod: changing permissions of 'admin/conf': Operation not permitted root@grey2011g2:~# chown -R root:root /home/admin/conf/ chown: changing ownership ...
1
vote
2answers
78 views

How to delete subfolders having only files of a specific extension

I want to delete subfolders, only if all its files are of some specific extension, say json. I have seen a similar question Find and copy directories containing file type. Thanks in advance. ├── ...
0
votes
2answers
39 views

Achieving the effect of a recursive rmdir

As far as I can see, rmdir might well have had the option -r, to remove the argument's reference only if it contained only directories and no file anywhere in the tree. What's the simplest way of ...
1
vote
1answer
654 views

What is the right approach to purge /var/spool/abrt/

We want to automate the process of removing old directories from /var/spool/abrt/. We have RHEL machines - version 7.x. The known way is to do the following # systemctl stop abrtd # systemctl stop ...
0
votes
1answer
28 views

How can i delete all files using pattern matching and recursively through directories

I have files in this format: 12.999.jpg 34.999.jpg 45.999.jpg 12.555.jpg So, for example I wish to delete all files that have '999' as part of the file name. But, these files can be in seperate ...
2
votes
0answers
31 views

Delete all folders except which are mapped in symlinks

I need to delete folders that are not in use. There are a few symlinks which points to this folder. My requirement here is in 3 step. 1) Get all the available folders at top level which are not ...
24
votes
2answers
4k views

Why does rm manual say that we can run it without any argument, when this is not true?

We can see that the synopsis of rm command is: rm [OPTION]... [FILE]... Doesn't it mean that we can use only rm command without any option or argument? When I run the command rm on its own, the ...
0
votes
2answers
132 views

Find and delete non empty folder older than 3 day

I want to find and delete non empty directories greater than 3 days. find . <Path> -mtime +3 -exec rm -rf "{}" \; I want to delete directories that have files in it and the directory and files ...
0
votes
2answers
134 views

Remove `target` folders in all subfolders

I need to remove a target folder in all subfolders.
2
votes
2answers
37 views

Delete directories that contain a certain file except directories starting with “!”

I'm trying to do as the title states. I have a server with a daily rotating movie list while I'm low on storage. I have a script that goes through and deletes the oldest .mp4. I'm left with left over ...
23
votes
4answers
3k views

What is :>filename.txt Doing?

:>filename.txt For example: root@box$ dd if=/dev/zero of=file.txt count=1024 bs=1024 1024+0 records in 1024+0 records out 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00536175 s, 196 MB/s root@box$ ...
0
votes
0answers
64 views

how does rm -rf \ works? [duplicate]

I know that rm -rf \deletes everything in the root. How does it work? To be more specific, when the files are getting deleted, won't the files associated with the 'deleting process' or the core files ...
2
votes
1answer
95 views

I've accidentally written 4 million small text files to a folder, how best to get rid of them?

Due to a script error (file_put_contents($text, $filename, FILE_APPEND) instead of file_put_contents($filename, $text, FILE_APPEND) I now have 4 million small text files in a folder. I'd rather not ...
1
vote
4answers
186 views

How to delete file in folder except name files in list.txt?

Assume in folder /photo have many files like 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg 6.jpg 7.jpg 8.jpg 9.jpg 10.jpg I have a file name nodeletelist.txt in this text file have name of not delete files list ...
0
votes
0answers
15 views

Weird behaviour of find -exec rm when using multiple name patterns [duplicate]

I would expect the following command to delete all files with extension .x or .z, but instead it seems to only delete the first file listed: mkdir foo touch foo/{a.x,b,c.z} find foo -type f -name '*....
0
votes
0answers
16 views

Can't delete files created by Time Machine on smb share (not immutable)

So I was trying to set up Time Machine backups on an unraid smb share for my MBP and had to stop it midway. So I went into my share to delete the files, but I just can not: server@server:/backups/....
0
votes
1answer
116 views

Permission denied when deleting file with sudo

I have quite a predicament. I have created a binary file /Library/Application Support/XXX/DaemonLauncher. When I try to delete it, I get the following: $ sudo rm -f /Library/Application\ Support/XXX/...
0
votes
1answer
99 views

Bash rm /proc/sys/net/ipv4/icmp_echo_ignore_all: Permission denied

I have created this file /proc/sys/net/ipv4/icmp_echo_ignore_all couple of months ago on my centos 7 server to disable ping requests permanently and now I can not undo this! I'm logged in as root ...
15
votes
3answers
2k views

“traversal failed: u: Bad message” when deleting an extremely large directory in Linux

I am trying to remove some extremely large directories, however no success. Here are some observations: # cwd contains the two larger directories $ ls -lhF drwxrwxr-x 2 hongxu hongxu 471M Oct 16 18:...
0
votes
0answers
26 views

Applications directory in home directory reappears after deletion

When I ran the AppImage for the Unity game editor, it created a directory called Applications in my home directory. Recently, I decided that I don't want to use Unity, and I deleted the Applications ...
2
votes
1answer
328 views

Can't delete persistent silly file

Linux Mint 18.3 (based on Ubuntu Xenial) This is a dual-boot machine with W10, which may be significant I'm trying to delete some backintime jobs. Using rm -rf top-level-dir doesn't work: I get an ...
0
votes
1answer
24 views

How to remove a setgid directory that links to another location?

I use an environment variable $DATAPATH that conveniently takes me to where I store my data. Idk what I did just now but I created a folder in my home directory called '$DATAPATH', and when I cd into ...
0
votes
1answer
48 views

How to recursively find file, concatenate into one file and simultaneously delete the original file

As I understand it, I could use find . -name '*.txt' -exec cat {} \; > all.txt to concatenate all the text files in a directory, recursively throughout sub-directories, into a file called all....
1
vote
2answers
33 views

Empty a specific folder in every subdirectory

When entering data in my filesystem, some files got into the wrong directory and now I have to reset all of the folders with a specific name, without touching the files in the other folders of that ...
2
votes
1answer
62 views

How can I delete a file with the name “*”? [duplicate]

Someone who isn't me ran dd if=/dev/zero of=* iflag=fullblock,count_bytes count=200G, so now there's a 200gb file taking up space on my filesystem. Is there a way to delete it without running rm * ?
0
votes
0answers
23 views

How to remove multiple HTML files in batch

Ubuntu 16.04 LTS, Gnome version 3.18.2 My desktop filled with multiple html pages (GHex editor output). binary00000000.html binary00000001.html binary00000002.html ... binary00043310.html How to ...
0
votes
1answer
53 views

Linux command-line to find duplicate files and only retain most recent

I have a directory which contains a huge number of XML files. They are labelled as filename_date_time_checksum.xml, which means I've got thousands of files which are identical but separated by ...
0
votes
0answers
839 views

rm: cannot remove '<Directory name>': Device or resource busy

I know there can be a lot of duplicates. I have gone through almost all of them (like lsof, fuser, etc) and I could not get it resolved. rm: cannot remove 'temp_p/sys': Device or resource busy ...
0
votes
0answers
72 views

Cannot rm broken NTFS link

I'm trying to use an old windows NTFS drive as extra storage on a raspberry pi. I tried to delete everything on it, but came across a problem where I can't remove two broken links. I can format the ...
2
votes
1answer
81 views

Bash copy command not working after file rename

I have this installer shell script in a bash script. I am doing a rename of the existing text file (backing it up). I remove old file Copy fresh file to the target dir mv /target/data.ini /target/...
0
votes
0answers
53 views

Linux Prompt Does not Recognize Yes/No answer when removing a file

I am using Centos 7. I tried to delete a file in the current directory as shown below: [root@myserver ~]# rm foo rm: remove regular file ‘foo’? yes The server does not recognize my 'yes' answer and ...
-3
votes
1answer
138 views

Please explain this shell script snippet with an rm command [duplicate]

I am a beginner to the unix scripts, can anyone please explain what does the below lines mean: BTEQTEMPDELLOGS=$LOGS/${tablename}.DELlog rm $BTEQTEMPDELLOGS 2>/dev/null 1>/dev/null
1
vote
1answer
50 views

Find (and delete) all files with hard link count = 1

I'm having a tough time trying to reclaim some unused disk space on one of my macOS 10.13 partitions. Thanks to GrandPerspective, I think I found out that every time I delete some items in Photos for ...

1
2 3 4 5
14