1
vote
3answers
160 views

Delete files with same name at the end of the file

Delete files with same name at the end of the file i have a lot of files in my folder and sub directories like ajax_hostel_room_master.php.php class_hostel_registration.php.php ...
2
votes
2answers
148 views

delete directory with special character in filename

I have these tricky directories that I can't figure out how to delete. If I run ls -ld * I get… drwxrwxr-x 7 user1 taskfmri 2048 Jan 22 15:26 857263 drwxrwx--- 4 user2 ...
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 ...
25
votes
1answer
1k views

Does 'rm .*' ever delete the parent directory?

The expression .* is expanded by bash to include the current and parent directories: $ ls -la total 2600 drwxrwxrwx 2 terdon terdon 2162688 Sep 10 16:22 . drwxr-xr-x 142 terdon terdon 491520 Sep ...
10
votes
4answers
5k views

rm -rf all files and all hidden files w/o . & .. error?

rm -rf /some/path/* deletes all non-hidden files in that dir (and subdirs). rm -rf /some/path/.* deletes all hidden files in that dir (but not subdirs) and also gives the following error/warning: ...
4
votes
4answers
919 views

How to remove files which do not end with “.c”?

I have a directory which contains all the C programs. I have also compiled them at the creation time so as to check my code. There are a lot of programs nearly 100 of them. So I want a BASH script ...
6
votes
3answers
2k views

How do I remove all sub-directories from within a directory?

This question is kind of a phase II to the first question I posted at here I have a directory that contains a bunch of sub-directories, .zip files, and other random files not contained within a ...
6
votes
2answers
384 views

Remove all Vim undo files in all but one directory

I just realized that I have tons of Vim undo (.un~) files sprinkled around my file system. I'd like to delete all of these files except in one directory—~/.tmp. My first problem is that I can't seem ...
2
votes
2answers
138 views

What is an equivalent of rm `find lib/ -name *.swp` without find?

As in the title, I would like to remove all files in the lib directory with .swp in the end. How can I do this without find in: rm `find lib/ -name *.swp`
13
votes
2answers
343 views

Can I make `rm` interactive only when using globbing? (in either bash or zsh or both)

Whenever I rm multiple items at once with shell globbing and there's even the slightest possibility that the pattern expands to more than I expect it to, I always try to remember to add -i, but (of ...
12
votes
3answers
5k views

How can I remove all symbolic links with a special target?

With the command: ls -la * I can list all my symbolic links. How can I remove all symbolic links which are linked to a special folder? For example: In my directory usr/local/bin I have the ...
4
votes
3answers
748 views

Delete matching file from every subfolder of current dir

I used this one to copy file in every dir: find -type d -maxdepth 1 -print0 | xargs -0 -n1 cp .htaccess Now i need to do reverse one and delete file with matching name from every sub directory of ...
9
votes
4answers
12k views

How do I recursively delete directories with wildcard?

I am working through SSH on a WD My Book World Edition. Basically I would like to start at a particular directory level, and recursively remove all sub-directories matching .Apple* - how would I go ...
5
votes
2answers
1k views

Why doesn't “rm *” work when there are files that begin with a hyphen?

from: http://seclists.org/fulldisclosure/2011/Sep/190 [USER@MACHINE ~] mkdir ejha [USER@MACHINE ~] cd ejha/ [USER@MACHINE ~/ejha] touch ize [USER@MACHINE ~/ejha] touch -- -f -i [USER@MACHINE ...
11
votes
8answers
2k views

How do I delete everything in a directory?

I'm sorry for asking such a basic question: How do I delete everything in a directory, including hidden files and directories? Right now, I use the following: rm -rf * rm -rf .*
1
vote
2answers
5k views

Delete files in a directory that match a regexp, using a Mac terminal

How do I delete files in a directory that match a given regexp, or a similar solution, using a Mac terminal?