rm

Delete all *mp3 files without confirmation and inside all folders /sub

Delete all *mp3 files without confirmation and inside all folders /sub I am now in the "upload" folder (centos 7) I want the files *mp3 which is inside this folder and the folders inside it without being constantly "y" Hit I use this code, but I have to go into each folder and run the …

Total answers: 1

Delete all files without user permissions

Delete all files without user permissions I have a prompt that asks me to delete all the files in a directory that the owner (u) can’t r, w, nor x, in one command. I tried this command: find data -type f ! -perm -u=rwx -exec rm -f {} ; … but I think it removes …

Total answers: 4

Suggest a safe command to delete files after a script used it

Suggest a safe command to delete files after a script used it I have this script where I would like to add a line that, after the concatenation, safely deletes the *.dump files, because they are big and I have no space for the concatenated files and the dump files. jelly is a txt that …

Total answers: 1

Accidentally deleted /dev directory

Accidentally deleted /dev directory I’ve accidentally performed sudo rm -fr /dev Will I suffer from data loss or any side effects? I’ve rebooted the system and my data seems ok, but I’m afraid there is hidden or non-obvious loss of data that I simply haven’t found out yet. EDIT: I’ve read this post but didn’t …

Total answers: 1

rm command contradictory options -i and -f

rm command contradictory options -i and -f I learned that -i option is interactive mode and -f option is force model in rm command. When I tried both options rm -if test.txt it did not ask me and just deleted it which means -f option overrode -i option. Of course, I would not use options …

Total answers: 2

Remove entire folder when grep find no files with a match inside the folder

Remove entire folder when grep find no files with a match inside the folder I have thousands of folders with a single html file in each folder. I want to remove the entire folder if grep find no match to example.com in the html file. I know how to remove the non matching file. For …

Total answers: 1

Find files and delete x from total of the list

Find files and delete x from total of the list I want to delete all log files in some directory, but not the latest 3. I’ve done: DATA_PATH=$(gadmin config get System.DataRoot) ZK_PATH=${DATA_PATH}/zk/version-2 log_count=$(ls -ltrh ${ZK_PATH} | grep log | wc -l) limit_files=`expr $log_count – 3` echo There is ${log_count} files found in ${ZK_PATH}, ${limit_files} will …

Total answers: 3

How can I delete non-mp3 files recursively using fish shell? [SOLVED]

How can I delete non-mp3 files recursively using fish shell? The tree list is like this: /Music |— folder1 |— folder2 |— folder3 | |—- folder3.1 | |—- folder3.2 | —- folder3.3 |— folder4 I had tried the command rm | ls -R | grep -v "*.mp3" Asked By: Leo_2233 || Source You can use …

Total answers: 1

How do I repair Ubuntu after running the command: sudo rm /*

How do I repair Ubuntu after running the command: sudo rm /* While I was trying to remove files from a SD card from the same directory, I ran sudo rm /* and now Ubuntu isn’t working. When I restarted I get the error: kernel panic attempted to kill init. I’m new to Linux. What …

Total answers: 2

How to remove similar folder from multiple locations in terminal

How to remove similar folder from multiple locations in terminal I have a folder ‘reg_standard’ nested within 68 different folders that I want to remove. The path to this folder looks something like: /Volumes/…/sub-???/run_?.feat/reg_standard where ‘?’ is a stand-in for all the different folders that start with ‘sub’ or ‘run’. For example, I have sub-101, …

Total answers: 2

Is it possible to recover a deleted directory?

Is it possible to recover a deleted directory? I deleted a directory using the command rm -drf file_dev as root. Is it possible to recover this directory with its content somehow? Asked By: sarp || Source Install testdisk, thank me later. Works about 99% of the time.The time that it didn’t is when you got …

Total answers: 1

Control the way git prints file names so that they can be passed to rm?

Control the way git prints file names so that they can be passed to rm? When I print a file from git using the command, there are edge cases: git diff –no-renames –name-only Edge case 1: spaces (added –diff-filter=D for illustrative purposes) # format 1: unquoted $: touch ‘foo bar.txt’ $: git add ‘foo bar.txt’ …

Total answers: 2

Cannot delete directories as sudo: Permission Denied

Cannot delete directories as sudo: Permission Denied I am trying to remove directories with files and getting a permission denied error on Ubuntu 22.04.1. I’ve changed permissions to 777 for the directory and the parent directory but I still get the error. $ sudo rm *.* rm: cannot remove ‘Real Economy v1.5.1-4267-1-5-1-1588544476’: Permission denied rm: …

Total answers: 2

In Bash, how can I rm files against a wildcard while supplying more than one exception?

In Bash, how can I rm files against a wildcard while supplying more than one exception? I have the following list of files: main.acn main.acr main.alg main.aux main.glg main.glo main.gls main.ist main.lof main.log main.lot main.nlo main.out main.pdf main.tex main.toc I want to rm all of the main.* files except for main.tex and main.pdf file. I …

Total answers: 4

How to make "yes" the default of rm -i

How to make "yes" the default of rm -i I want to review a long list of files from being deleted, they are not very important so there is no problem if I accidentally delete some of them, but still I want to save some. How can I call rm -i ./* and be prompted …

Total answers: 2

Delete huge directory that causes all commands to hang

Delete huge directory that causes all commands to hang How do I delete this large directory? stat session/ File: ‘session/’ Size: 321540096 Blocks: 628040 IO Block: 4096 directory Device: 903h/2307d Inode: 11149319 Links: 2 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2022-09-29 14:34:40.910894275 +0200 Modify: 2022-09-29 14:35:09.598400050 +0200 Change: 2022-09-29 14:35:09.598400050 …

Total answers: 3

`find` removed top-level directory as well as contents

`find` removed top-level directory as well as contents I ran /bin/find /home/user/myfiles ! -name ‘.htaccess’ -exec rm -r {} ; and it removed everything in myfiles and the myfiles directory itself if .htaccess doesn’t exist. What I was expecting is that it would find and remove files within the directory, except for any .htacess file. …

Total answers: 4

Home folder contents lost: wrong use of rm?

Home folder contents lost: wrong use of rm? I am using Ubuntu-Mate 20.04 and I have lost most of the contents of my home folder. I think it could be due to using wrongly the “rm” command with sudo, but not sure if it might be something else. I explain: I was trying to delete …

Total answers: 1

how to remove file 0= file which has srw permission

how to remove file 0= file which has srw permission How can I remove below file? srwxrwxrwx 1 patroh root 0 Aug 8 16:11 0= The user patroh is myself. The rm command won’t work – it doesn’t give any error when I execute rm 0. I am not sure how I created this file? …

Total answers: 1