Questions tagged [delete]
The delete tag has no usage guidance.
263
questions
0
votes
0
answers
21
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 ...
1
vote
3
answers
314
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. ...
0
votes
0
answers
89
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 ...
3
votes
3
answers
695
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. ...
0
votes
1
answer
133
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\...
1
vote
2
answers
79
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 ...
0
votes
1
answer
56
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 ...
0
votes
2
answers
1k
views
The dd command is enaugh to delete all data from an hard disk?
I need to remove all data from an hard disk where is installed lubuntu 22.04. I was thinking to boot from an Ubuntu liveUSB image and, from a terminal, use the command:
# the Hard Disk is the device ...
0
votes
1
answer
111
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 "...
0
votes
0
answers
35
views
Remove all Linux Distro's and keep Linux Mint
Long time ago, I was experimenting with Linux. And by experimenting, I mean installing some Linux Distro's on my main PC to see which Linux Distro I like. And now I want to remove 2 out of 3 Distro's, ...
-1
votes
1
answer
138
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
...
0
votes
0
answers
1k
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 ...
3
votes
3
answers
1k
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, ...
0
votes
1
answer
52
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 ...
0
votes
2
answers
66
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 ...
0
votes
0
answers
102
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 ...
1
vote
2
answers
345
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 ...
0
votes
2
answers
116
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 ...
1
vote
1
answer
179
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 ...
1
vote
4
answers
197
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
...
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 ...
0
votes
3
answers
386
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" > ...
0
votes
1
answer
82
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 ...
0
votes
0
answers
128
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 ...
6
votes
3
answers
611
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: ...
1
vote
1
answer
205
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 ...
2
votes
2
answers
508
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?...
1
vote
0
answers
89
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 ...
1
vote
1
answer
230
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
2
votes
1
answer
1k
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 ...
0
votes
3
answers
67
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/...
1
vote
2
answers
35
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 ...
0
votes
1
answer
229
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 ...
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 ...
0
votes
1
answer
54
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.
...
0
votes
2
answers
68
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 &...
0
votes
1
answer
96
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 ...
-2
votes
2
answers
420
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
...
0
votes
1
answer
59
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 ...
25
votes
1
answer
3k
views
Unable to delete this file as root [duplicate]
I'm unable to delete a file with rm -rf /home/wordpress/testDomain.com from my Linux machine. Instead of the file being deleted, I get an Operation not permitted error. How can I fix this?
$ cd /home/...
16
votes
4
answers
3k
views
Delete a file called '.env'$'\r'
I have no idea what created this file - I guess a terrible shell script.
It is called '.env'$'\r'
I have tried various versions of rm, and the technique of opening the direcory with vim ./, selecting ...
0
votes
1
answer
374
views
Deleting files using xargs prints lots of No such file or directory (but seems to work...)
I have a script that deletes files older than N minutes. The script basically runs:
find /some-folder/* -mmin +59 | xargs rm -rf
But for some reason it prints tons of: No such file or directory but ...
-1
votes
1
answer
50
views
Search & replace for a string separated by whitespace upon substring match found
Below is a sample file content:
cat sample.txt
-server -XX:+UseParallelGC -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+AggressiveHeap -XX:+PrintHeapAtGC -Djava.util.logging.FileHandler....
1
vote
3
answers
265
views
Where is the undo button in Linux? If I created an SSH key and copied the public key to a NAS, how would I undo or delete it?
I created an SSH key using ssh-keygen -t rsa.
Then I copied the key to the NAS, so I wouldn't have to enter a password using ssh-copy-id.
I realized that I did it for the wrong user, so now I need to ...
0
votes
1
answer
38
views
In bash, how do I delete child directories older than the date that another directory was created?
I can use the following command to delete child directories in a particular directory older than x number of days
find /path/to/base/dir/* -type d -ctime +10 -exec rm -rf {} \;
but how would I delete ...
1
vote
2
answers
958
views
What is emacsen-common package?
I was trying to remove emacs and all packages related and almost removed emacsen-common.
The output to apt remove emacsen-common is:
Reading package lists... Done
Building dependency tree... Done
...
2
votes
2
answers
6k
views
can't delete file from Ubuntu subsystem on Windows 10 Enterprise
This probably is the wrong forum, but I'll give it a go anyway. I'm running the ubuntu subsystem in Windows 10 Enterprise:
root@hostname:/directory/stuff# cat /etc/*release
DISTRIB_ID=Ubuntu
...
1
vote
2
answers
532
views
Remove directory, except when pointed to by symbolic link
I have the below directory structure. I need to find the directories in which a file called log.xml exists and remove all of them completely, except the directory which is pointed to by a specific ...
1
vote
1
answer
8k
views
Cron job to delete all files older than 7 days: -exec rm -f {} \; vs -delete [duplicate]
I want to run a cron job which deletes .txt files older than 7 days. I have two commands.
The first command:
/usr/bin/find /var/www/example.com/wp-content/targetdir -name "*.txt" -type f -...
0
votes
0
answers
4k
views
How can i remove/delete a repo i cloned from git?
I cloned a repo twice, first, I cloned at home. second, I created a folder and cloned it again in the folder. now I cannot delete any of the repo...even the folder I created. Any soln?