Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I'm trying to use a combination of find -exec and grep with little success.
Basically, I need a script to search for files modified within the last day that match a certain filenaming pattern. I then need to execute a command on these files. The key however is that it needs to be case insensitive.
Eg.
20781 Oct 28 10:29 test1.txt
499 Oct 28 10:29 test2.txt
77 Oct 28 10:29 TEST.txtNeed to be able to find and remove all files modified on Oct 28 with the filename containing "test" (case insensitive) in it. (Assuming today is Oct 29)
This is what I've come up with, but it removes all files in my directory (not just ones matching "test". I suppose this is because grep is only cosmetic, and has not affect on the results of the find command?
find . -mtime -1 -exec rm {} \; | grep -i "test"
Sorry I'm new to unix. Please bare with me.
Thanks in advance.

Thanks. Unforunately I am on Solaris 8, and the find command doesn't have a -iname switch.
Any other suggestions?

This one should be more elegant if you have to deal with things like "tEsT":
find . -name "[Tt][Ee][Ss][Tt]*" -mtime -1 -exec rm {} \;

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |