Help with rm command with wildcards


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with rm command with wildcards
# 1  
Old 07-08-2011
Help with rm command with wildcards

Hello everyone. My first time posting here.

I have a question that may seem very insignificant to some but is one that I've been trying to address for the past several days (haven't had any luck looking online).

I'm trying to clean a directory by removing old files that we no longer need. I'm using wildcards to do this but I am finding that, because of how the files are named, it's taking quite a bit of time to remove all of them. Just to allow for a clearer understanding of what I'm talking about, here's an example of the types of files I'm dealing with:

Code:
loep_April-01-2010_14:30:00
loep_April-02-2010_14:30:01
loep_April-03-2010_14:30:00
loep_May-01-2010_14:30:00
loep_May-02-2010_14:30:00
loep_May-03-2010_14:30:00
loep_June-01-2010_14:30:00
loep_June-02-2010_14:30:00
loep_June-03-2010_14:30:00

I've been, so far, removing these files one month at a time using this command:

rm loep_April-??-2010*

The problem is that with the above command I can only delete those files from April which, consequently, slows me down significantly since I have to do the same for May, June, August, etc.... So, my question is, is there any other way for me to actually delete all files for, say, 2010 without doing it month by month? I've tried several combinations of the above command, placing the wildcard right after loep, etc., but without success.

Any help on this will be appreciated.

Rob

Last edited by radoulov; 07-08-2011 at 02:17 PM.. Reason: Code tags.
# 2  
Old 07-08-2011
Why don't you use loep_*-2010_*?
Or that pattern matches files that shouldn't be removed?
# 3  
Old 07-11-2011
Or:
Code:
loep_*-??-2010_??:??:??

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find command and use of wildcards

greetings, below is the find command i am using for some filesystem maintenance: find /data/Engine \( -type d -name .snapshot -prune -o -type d -wholename "/data/Engine/*/CAE" \ -prune -o -type d -wholename "/data/Engine/*/CAD" -prune -o -name ".*.case" \)\ -mtime +365 -print0 -fls... (5 Replies)
Discussion started by: crimso
5 Replies

2. Shell Programming and Scripting

Date with Wildcards in Command

I have the following script (parts from help on this forum, thanks y'all): #!/usr/bin/ksh date '+%m %d %Y' | { read MONTH DAY YEAR DAY=`expr "$DAY" - 1` case "$DAY" in 0) MONTH=`expr "$MONTH" - 1` case "$MONTH" in 0) ... (5 Replies)
Discussion started by: he204035
5 Replies

3. UNIX for Advanced & Expert Users

Wildcards

These 2 websites do a GREAT job of explaining different types of wildcards. I learned about the categories of characters which I never knew about at all. GNU/Linux Command-Line Tools Guide - Wildcards GREP (1 Reply)
Discussion started by: cokedude
1 Replies

4. UNIX for Dummies Questions & Answers

wildcards in path

Is there some rule about using wildcards in path? Say I want to create a file, but one of the directories in the path is called 1433d.default and on different machines it will be called <some other string>.default touch ~/Library/Application/*.default/myfile In theory I thought that... (5 Replies)
Discussion started by: glev2005
5 Replies

5. UNIX for Dummies Questions & Answers

wildcards NOT

Hi All Please excuse another straightforward question. When creating a tar archive from a directory I am attempting to use wildcards to eliminate certain filetypes (otherwise the archive gets too large). So I am looking for something along these lines. tar -cf archive.tar * <minus all *.rst... (5 Replies)
Discussion started by: C3000
5 Replies

6. Shell Programming and Scripting

using wildcards in this perl command

Hi there, is it possible to use wild cards in this statement ssh $remote_server 'perl -pi -e "s,EXP_SERIAL_19b8be67=\"\",EXP_SERIAL_`hostid`=\"UNKNOWN\"," /var/myfile' This command works fine but the bit in bold (the 8 character hostid) will not always be 19b8be67 so I was hoping I could... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

7. UNIX for Dummies Questions & Answers

ls with wildcards

ok, I'm trying to write a script file that lists files with specific elements in the name into a txt file, it looks like this ls s*.dat > file_names.txt can't figure out whats wrong with that line, any ideas? thanks in advance (10 Replies)
Discussion started by: benu302000
10 Replies

8. UNIX for Dummies Questions & Answers

wildcards

when writing a shell script (bourne) and using a unix command like 'ls' is there anything special you need to do to use a wildcard (like *)? (3 Replies)
Discussion started by: benu302000
3 Replies

9. UNIX for Dummies Questions & Answers

Wildcards In UNIX

on my SCO UNIX wild cards are not displaying wanted result. Why like that . I think that i was not using proper command . what are there . how can i use the wildcards in UNIX. (7 Replies)
Discussion started by: smdakram
7 Replies

10. UNIX for Dummies Questions & Answers

Wildcards in VI

I'm trying to delete lines from a large text file using VI. Every line that I am wanting to delete start with 'S' - all others do not. (A list of users) I've tried using * but doesn't seem to like it...any ideas... Doesn't have to be VI - but I'm better with VI than sed/awk. (8 Replies)
Discussion started by: peter.herlihy
8 Replies
Login or Register to Ask a Question