Skip to main content

Questions tagged [delete]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
53 views

Delete files in Multiple Folders older than 30 days

I have a root directory: /opt/abc/logs/EXPORT inside of that directory, I have 17 other directories /opt/abc/logs/EXPORT/1 /opt/abc/logs/EXPORT/2 /opt/abc/logs/EXPORT/etc /opt/abc/logs/EXPORT/17 ...
johnfli's user avatar
  • 13
0 votes
0 answers
34 views

Deleting incremental backups created with rsync and symbolic links: recursive effect?

I am doing incremental backup according to the following example found there: https://linuxconfig.org/how-to-create-incremental-backups-using-rsync-on-linux #!/bin/bash # A script to perform ...
ecjb's user avatar
  • 455
-1 votes
1 answer
42 views

Single command to delete all files in a folder & the folder itself if it is now empty?

Sometimes I want to delete all the writable files in a folder and delete the folder itself if it is now empty (meaning it did not have any subfolders, and did not have any write-protected files). I ...
End Antisemitic Hate's user avatar
0 votes
0 answers
9 views

How to use ctrl and command hot keys for deleting entire lines, words in macbook terminal?

I don't know what this feature is called, but in text editors, word documents, pretty much everywhere you can type text, and even here on stackexchange, I can press command + delete to delete an ...
roulette01's user avatar
0 votes
2 answers
39 views

Delete certain files from specific date in linux [duplicate]

I need a command how I can delete files from a folder with specific date. Like I want to delete files before 20 April from a folder on /home/FTP and file types are mp4.
White hat Mahmud's user avatar
1 vote
1 answer
2k views

How to clean up a Linux system to free up disk space?

What are some generic ways to free up lots of storage space without deleting personal files? I'm doing a distro upgrade (Debian11->12) and it needs lots of disk space on the root partition / which ...
mYnDstrEAm's user avatar
  • 4,398
1 vote
1 answer
25 views

After deleting "database-wal" file from kactivitymanagerd which suddently had a size of several GBs disk space is not freed up

After upgrading to Debian 12 with KDE multiple issues appeared. The following was the most problematic: A database-wal file with a size of multiple GB appeared and I had to delete it like so rm ~/....
mYnDstrEAm's user avatar
  • 4,398
1 vote
2 answers
99 views

Delete directory and create new one with same name and permissions [closed]

I want to delete a directory with its contents recursively, and then re-create it with the same name and permissions. That directory may or may not be created or owned by me earlier before delete, but ...
Vicky Dev's user avatar
  • 259
-1 votes
1 answer
58 views

How to delete all "stuff" (dir and files) older than x days?

I am aware of find -mtime +x -delete, but how do I use it - or use it in a script - in order to delete all the "old stuff" (including hidden files) ? Eg, if I have a dir target_dir: delete ...
Antonello's user avatar
  • 1,043
5 votes
2 answers
4k views

Accidentally ran `rm -rf /home`

Note that the command I accidentally ran was to recursively delete the root home directory, not the user one. Also not I do not have sudo nor root privileges. This is not a question about data ...
Sergio Gliesh's user avatar
2 votes
3 answers
610 views

Disk space is not freed up when deleting files on a hard drive

After deleting files on a veracrypt-encrypted drive with no disk space left, no disk space is freed up. I'm trying to sync a hard drive to another one as described here. That target drive is full and ...
mYnDstrEAm's user avatar
  • 4,398
0 votes
2 answers
95 views

Erase external SSD completely, including SWAP

I have an external SSD which I need completely wiped. I had Mint installed on it, with SWAP and some root dir. Those I somehow cannot get rid off. I tried sudo dd but that just wipes sdc and those ...
Boq7's user avatar
  • 3
0 votes
0 answers
22 views

Linux home dir has a "duplicate" under /home/music but when anything is deleted from one it disappears from both -- how can I delete 2nd home dir?

I don't know where the 2nd "phantom" home dir came from. Properties folder shows it's 4K. The "real" home directory is 128,000+ files and 208GB. User10489 had the answer: a symlink ...
R E Brinson's user avatar
1 vote
3 answers
423 views

How to remove files according to their MIME type?

(Hello! And especially hello to everyone as it is my first post here.) I want to remove files according to their MIME type with a command, in a folder and its sub-folders, say .webp and .png pictures. ...
UnixToo's user avatar
  • 11
0 votes
0 answers
131 views

Samba file/folder deletion error after Debian 12 upgrade

I recently installed Debian 12 for Raspberry Pi and configured a Samba server. But now when I delete a file or a folder over the network I get an error, Samba object not found and then the file or ...
Neha's user avatar
  • 1
3 votes
3 answers
890 views

How can I remove everything except last n bytes from the file in Linux?

I've a Tomcat server where logs are stored as catalina.out. It's a pretty huge file and causes troubles a lot of times. Because of it taking too much space, other servers have to stop involunatarily. ...
achhainsan's user avatar
0 votes
1 answer
449 views

Delete all the files in a folder and its subfolders without deleting the folder structure

I am replicating a server -> I want to delete all the files inside the folders and the subfolders, without deleting the directories themselves. Example: home\apps\Batches\hello.txt home\...
amalAF's user avatar
  • 3
1 vote
2 answers
129 views

Delete files older than 15 days except for monthly and annual versions

I use a simple find script to delete backup tar files older than 30 days, but in the interest of historical preservation and having the ability to look back further, I'd like to switch to keeping the ...
user162124's user avatar
0 votes
1 answer
57 views

Why doesn't find / -delete hose the entire system

I ran the command sudo find / -mtime +100 -delete The damage was such that when I pressed ENTER on the console it no longer presented a login prompt. Later on examining the wreckage I found that the ...
VagrantPaladin's user avatar
0 votes
3 answers
6k views

Is the dd command enough to delete all data from a hard disk?

I need to remove all data from an hard disk where lubuntu 22.04 is installed. I was thinking to boot from an Ubuntu liveUSB image and, from a terminal, use the command: # the Hard Disk is the device ...
User051209's user avatar
0 votes
1 answer
281 views

could not delete file in trash

I have a file named "1" maybe it was created by using the wrong command when using redirect. Such as: commond 2>&1 1>/dev/null When I try to empty the trash, the file named "...
black gary's user avatar
-1 votes
1 answer
194 views

Linux Bash Shell Script - To Find Files with Zero Size and Delete

List of files are stored in a variable REMOVEFILES. Script need to verify the list of files one by one and if the file is ZERO in size, it should be deleted. Please help me fixing it. #!/bin/bash ...
dbadmin's user avatar
  • 23
0 votes
0 answers
2k views

Can't delete folder: rm: cannot remove: Directory not empty

I'm trying to delete a folder I once created and nothing happens when you try to remove the file in the file explorer. I tried to remove the file per command line: rm -rf folder-path/ This is where i ...
Robbie Sumner's user avatar
4 votes
3 answers
2k views

How do I delete files with the same names in multiple sub-folders from the command line?

I have a folder called simulations, which contains 101 subfolders. These sub-folders are named posterior_predictive_sim_1 to posterior_predictive_sim_101. Each subfolder contains five files: seq.nex, ...
Namenlos's user avatar
  • 141
0 votes
1 answer
68 views

Linux Trash implementation: Correct place for a Trash Log?

I am working on a Trash implementation and would like to store a log for every deletion. I have reviewed the Freedesktop Trash Specification but couldn't find any information about where to store a ...
127 001's user avatar
0 votes
2 answers
95 views

Delete files with similar names

I have been away from scripting for years, so I was wondering if someone can help in the below. I am migrating from Google Photos to Amazon Photos (about 40k photos). Here is an example of what I ...
HimaTech's user avatar
0 votes
0 answers
143 views

Fedora 37: cannot remove fwupdate-efi fwupdate-libs

This box was originally Fedora 21 I think, and has been updated a few times like 21 -> 23 -> 25 -> ... -> 25 -> 37 (every odd version), and works fine. However, I cannot clean these two ...
Paavo Leinonen's user avatar
1 vote
2 answers
669 views

I made a mess while reinstalling a distro, how can I FULLY and properly remove a distro from my computer?

(disclaimer: I am… a certified noob) I think I made a real mess while installing EndeavourOS (gonna call it EOS for short) and then trying to kind-of reinstall it… so I might need an advice of someone ...
blindfolded's user avatar
0 votes
2 answers
126 views

Need help with a command to find all filenames that are too long and delete from a directory

I have been using the following command: find . | awk 'function base(f){sub(".*/", "", f); return f;} \ {print length(base($0)), $0}'| sort -nr | head -2 It will find some files ...
linuxuser24569's user avatar
1 vote
1 answer
273 views

Does rm -rf /mnt/ delete files in subfolders if you do not have write access to /mnt/?

I accidentally ended up with rm -rf some-text-folder-I-had-already-deleted-previously.txt /mnt/ because of arrow up into bash history. My screen flashed with lots of subfolders that I actually do have ...
jmkane's user avatar
  • 111
1 vote
4 answers
211 views

How can I remove files that have an unknown number in them?

I have some code that writes out files with names like this: body00123.txt body00124.txt body00125.txt body-1-2126.txt body-1-2127.txt body-1-2128.txt body-3-3129.txt body-3-3130.txt body-3-3131.txt ...
display_name_1's user avatar
1 vote
1 answer
1k views

i deleted the python3.9 folder from /usr/lib and i can't install it again

i did a stupid mistake by deleting the python3.9 folder from /usr/bin as well as other folders (it's a long story why i did that). when i tried to reinstall it by running sudo apt install python3.9 i ...
Colton Walker's user avatar
0 votes
3 answers
509 views

How to remove lines from TSV file where columns are empty or all whitespace?

I've a tab-delimited file, e.g. myfile.tsv: abc\tfoo xyz\tbar but sometimes, it has some blank columns, e.g. abc\tfoo xyz\tbar what\t \tthe bleep\tsleep i.e. $ printf "abc\tfoo\n" > ...
alvas's user avatar
  • 123
0 votes
1 answer
105 views

Can't remove element from the array

Does anyone can explain me why the pid is not deleted from my pids list ? The for loop still occure the same number of time each time I go in this The var i is equal of the number of pids. So the loop ...
Kaleikini O'CONNOR's user avatar
0 votes
0 answers
171 views

Move or delete file out of folder if detox reports "cannot rename"

I'm backing up recipes in a folder to a backup drive. I use cp -vnpr /folder/* bkdrive/folder so not overwriting or copying same files over and over. Works well. Then I started getting copy problems ...
Click__'s user avatar
6 votes
4 answers
1k views

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: ...
Bojan Hrnkas's user avatar
1 vote
1 answer
563 views

What is the appropriate way to create a new user, switch to that user, then delete the old user

In a new server, I want to create a user, switch to that user, and then delete the old user completely. I currently do the following: # create new user sudo useradd -m -s /bin/bash newuser sudo passwd ...
angryserver's user avatar
2 votes
2 answers
670 views

Delete multiline blocks with sed non-greedy

How can one remove code blocks starting with /** START */ and ending with /** END */ using sed non-greedily considering that code blocks are multiline and empty lines may occur within START-END blocks?...
0x1505's user avatar
  • 23
1 vote
0 answers
104 views

I removed Bluez, but now cannot get back to GUI

Bluetooth has always been a problem. In the past, I tinkered with a few things in the command line and got it to work. then it stopped again, so I just left it alone. Well, it turns out I wanted to ...
user542453's user avatar
1 vote
1 answer
301 views

How to sort a list of strings that contain a combination of letters and numbers

I want to sort following strings by the number and remove duplication in a file cat311 celine434 celine434 celine5 jimmy12 john44 john41 to be celine5 jimmy12 john41 john44 cat311 celine434
user8090410's user avatar
3 votes
2 answers
2k views

How do I delete a specific element in a chain in nftables?

Current system: Distro: Ubuntu 20.04 kernel: 5.4.0-124-generic nft: nftables v0.9.3 (Topsy) I am new and learning nftables, Here is my nft ruleset currently: $sudo nft list ruleset ...
Dave's user avatar
  • 621
0 votes
3 answers
76 views

File that can be securely deleted without affecting system

I'm trying to make one of my shell scripts a little bit safer. I thought about using the default value if for some reason the variable is not defined something like: rm -r "${OUTPUT_DIR:-/dev/...
Alex Baranowski's user avatar
1 vote
2 answers
42 views

How can I delete everything before and afrer match pattern from pdb file?

I'm beginner in bash scripts, but I try to delete everything in my pdb file (test.pdb) before REMARK time 20.00 and from REMARK time 30.00 to the end of this file. I'm using to this sed command, which ...
skywalker's user avatar
0 votes
1 answer
312 views

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 ...
Rocky's user avatar
  • 3
0 votes
0 answers
19 views

Check which files in directory A are already contained somewher in directory structure B

I have a neatly organized folder structure with subfolders which contains jpegs (directory structure B). I also have several unorganized folders of jpegs (directory A). I would like to delete all ...
TorbenKorx's user avatar
0 votes
1 answer
94 views

Conditionally deleting duplicate files with different extensions with extension priority?

I have a large directory of files where there are duplicate filenames but different extensions. What I would like to do is remove the duplicates but have a priority order of which extension gets kept. ...
TimR75's user avatar
  • 133
0 votes
2 answers
92 views

Bash - How to make a function "delete only non-matching array from user inputs"

Suppose, I have 1 file in a folder named B.py Using this script, I make 3 files within that folder. The files are A.py B.py C.py. read -r -p "Enter the filenames: " -a arr for filenames in &...
Mega Bang's user avatar
  • 159
0 votes
1 answer
114 views

How to protect removal of a subfolder (namely .git folder) via ACL?

I've a quite big archive of git repositories in my development path, and many of them contains branches or stashes that I may have not published around. However I want to be sure that for no reason I ...
Treviño's user avatar
  • 182
-2 votes
2 answers
525 views

I want to Check two patterns in two consecutive line and delete the first line if the second pattern matches in the following line [closed]

I want to Check two patterns(a1 and a2) in two consecutive line and delete the first line(line having pattern a1) if the second pattern(a2) matches in the following line Input a1 b1 a1 a2 c1 c2 a1 b1 ...
Gaurav's user avatar
  • 21
0 votes
1 answer
61 views

How to delete entire directory fast in under 1 hour that contains millions of files and nearly 18TB of data? [closed]

My backup program backed up entire other drives multiple times by accident to one of my large drives and therefore hogged the entire drive. I already have backed up to another drive what I need from ...
user avatar

1
2 3 4 5 6