1
vote
2answers
40 views

Delete old files but keep one each week/month/year

I have a folder with log-files each ~10 minutes: alfred_140810-190001.json alfred_140810-191001.json alfred_140810-192002.json alfred_140810-193001.json alfred_140810-194001.json ...
0
votes
0answers
37 views

How to remove files except a list with names files [duplicate]

I need delete some .desktop files in various directories and a text file with a list of file names. I want to delete all these .desktop files except for those listed in my text file). Example $ ls ...
3
votes
2answers
100 views

Deleted /tmp accidently

Accidently, I ran sudo rm -r /tmp, is that a problem ? I recreated it using sudo mkdir /tmp, does that fix the problem ? After I recreated the directory, In the places section in the sidebar in ...
3
votes
2answers
59 views

Cannot delete File on Fedora

I have a file with following permission: -rwSr-s---. 1 1634630331 1818884080 118784 Jun 29 1970 DailyUpdateClass.class If I try to delete this file with root login, I get error. rm: cannot remove ...
0
votes
1answer
61 views

Delete ghost files with special characters

I have read several ways to delete files with special characters, but none of them works for me in one special folder in my cache system. I have no idea how the files got there, and why they turned ...
0
votes
1answer
56 views

How do I delete a file in a read-only directory?

I've got a directory and a file in it, with the directory marked as read-only: $ mkdir directoryname $ touch directoryname/filename $ chmod a-w directoryname I cannot delete the file, even if pass ...
28
votes
8answers
2k views

How to delete this undeletable directory?

I untarred a corrupt tar file, and managed to end up with some directory that I can not delete, If I try to delete it, it seems like it can not be found, but ls shows it's present, both with bash and ...
3
votes
2answers
84 views

fdupes - delete files after comparing two directories

I'm currently trying to solve an issue using fdupes. I'd like to compare two folders with each other, and afterwards delete all duplicate files within one of these directories. Example: Files are ...
4
votes
2answers
515 views

“no such file or directory” message when deleting a file that exists on NTFS

I have a directory with images. Suddenly I found out that there's a new image with a new name. The image content is similar to another image in another directory but with a different name. I didn't ...
1
vote
1answer
54 views

Minimum file permissions to delete a file [duplicate]

To delete a file in Linux: What minimal permissions do we need to set on it? What minimal permissions do we need to set on its parent directory?
3
votes
1answer
2k views

Cron job to delete files older than 3 days

I need to remove files older than 3 days with a cron job in 3 different directories. (these 3 directories are children of a parent directory /a/b/c/1 & /a/b/c/2 & /a/b/c/3) Can this be done ...
1
vote
2answers
252 views

Free disk space from a JBoss log file which is still being written to

Is there any locking on the content, imposed by the process if at all the process is using the file. We host a JBoss app server on a RHEL 6.4 OS and due to the disk space constraints we have decided ...
2
votes
2answers
1k views

delete old log files except the last one (alphanumerically sorted)

I have a number of log files in the form: log.2014-02-19-10_24_22 I.e. log.YYYY-MM-DD-H24_MI_SS The date that's part of the log file's name is when the log file was first created. So at any given ...
4
votes
4answers
261 views

Keeping the number of files in the folder constant by deleting old files

I'm trying to create a script and run it in crontab every 5 min, so that the number of files in a folder always remain 50000. If there are more, I want the script to delete the old files. ...
3
votes
2answers
529 views

grep string from contents of file command then delete file

I have a peculiar problem I need help with. I have a large batch of .docx files where a certain number of them are junk. I know how to identify these files from the file command, as they contain the ...
0
votes
1answer
556 views

Delete all 'nohup.out' within a directory recursively

How can I delete all 'nohup.out' files within a directory recursively from my terminal? I'm using CentOS.
3
votes
3answers
1k views

How to delete 2 months back files in unix

Say I have below log files, AA_XX_20130719185428.log exec_xxx_cpb_20130712182453.log 13122013121327_AR_INC_DOBC_1.dprf.log 24122013_masterscript.LOG Date part contains both date and time. I want ...
1
vote
1answer
485 views

Where is the trash folder in FreeBSD / PCBSD?

I'd like to delete - undelete files using the shell in PCBSD. But... I don't know where the "trash" folder is. Can anyone tell me?
4
votes
1answer
6k views

Move files and delete directories with rsync?

Recently I needed to delete a large number of files (over 1 million) and I read that doing: rsync -av --delete `mktemp -d`/ ~/source && rmdir ~/source Was one of the most optimized ways to ...
0
votes
3answers
236 views

What does ./ mean? [duplicate]

I'm having a hard time getting what ./ does. In the Linux Essentials books, it asks me in an exercise to delete a file named -file. After googling, I found that I need to do rm ./-file but I don't ...
0
votes
3answers
572 views

Rm command recovery for this situation

İn my desktop, i have a dir. called exam, and i wanted to remove it from the console and wrote rm * /exam, and apparently it removed some other files from my desktop. Please tell me that there is a ...
2
votes
1answer
660 views

“rm -rf Filename.iso ” Permission denied

Hi I am facing an issue while deleting an .iso file from Linux x86_64 GNU/Linux. Here are the permissions for the file: # ls -lrt -rwxrwxr-x 1 dev devgrp 2687934464 Apr 12 14:13 ...
5
votes
5answers
3k views

Delete files in directory without erroring if it's already empty

As part of a deployment script, I want to dump some cached stuff from my temp directory. I use a command like: rm /tmp/our_cache/* However, if /tmp/our_cache is empty (fairly common when pushing ...
1
vote
1answer
175 views

How to find undeletable files that were removed?

I just created a file: touch myFile Made it "undeletable": chattr +u myFile and removed it: rm myfile How can I get it back? What is the purpose of "u"? Is it used?
3
votes
2answers
780 views

rm -fr not working

I have a directory that was generated by mistake by an application and this directory has a structure that involves more than 2000 directories, one inside a another, something like: Directory aaaa ...
0
votes
1answer
843 views

Shell script to delete all files which are older [duplicate]

Possible Duplicate: Deleting files by age Write a shell script to delete all the files which are "n" of older that current day, where n can be 3days. 2days, or 1 year etc. The above script ...
6
votes
1answer
5k views

Cannot delete a file - permission denied - why?

[db2inst1][testing ~/sqllib/db2dump] rm db2diag.log rm: cannot remove `db2diag.log': Permission denied [db2inst1][testing ~/sqllib/db2dump] id uid=1002(db2inst1) gid=107(db2iadm1) ...
32
votes
2answers
14k views

Why can rm remove read-only files?

If I create a file and then change its permissions to 444 (read-only), how come rm can remove it? If I do this: echo test > test.txt chmod 444 test.txt rm test.txt ...rm will ask if I want to ...
8
votes
2answers
8k views

Locate and delete all temporary files in user directory

I use vim a lot, and my area has power failure a lot. So the resultant is I get many *.swp files scattered over my PC. I want an alias of rm command that removes all files with either .swp, ~, ...
4
votes
1answer
36k views

How do I remove a directory and all its subdirectories?

I'm trying to learn some directory navigagtion with bash and all I know is that rmdir directoryname will remove the directory but not if it's containing something. Is there a way to force it to ...
22
votes
12answers
29k views

Efficiently delete large directory containing thousands of files

We have an issue with a folder becoming unwieldy with hundreds of thousands of tiny files. There are so many files that performing rm -rf returns an error and instead what we need to do is something ...
5
votes
1answer
3k views

mv file without write permission to the source file

I just realised that I can move a file that I do not own and don't have write permissions on. I have write permissions to the directory, so I am guessing that is why I could move it, but in this ...
4
votes
3answers
2k views

Delete files based on year

I need to delete all files in a directory that were created in 2009. What command can I use to do that?
2
votes
3answers
1k views

Delete files if contents do not match pattern

There are hundreds of .html files in a directory. I need to delete files that don't contain word bluecar in their contents. I thought sed with rm would do that, but I don't know how to combine them.
4
votes
2answers
717 views

rm -rf failing if deleting in parallel

rm -rf will fail if something tries to delete the same file tree (I think because rm enumerates the files first, then deletes). A simple test: # Terminal 1 for i in `seq 1 1000`; do mkdir -p ...