1834448 Members
2148 Online
110067 Solutions
New Discussion

parameter with find

 
SOLVED
Go to solution
Jairo Campana
Trusted Contributor

parameter with find

hello , I want to erase the archives *.HTM y *.png but old 15 day, in the directory too exist files .gif and .jpg that I do not want to erase

both display all files (ll replace for rm)

#find . -mtime +15 -exec ll {} \;

#find . -mtime +15 -exec ll *.HTM {} \;

as I avoid that display all files .gif and .jpg

thanks




legionx
5 REPLIES 5
Pete Randall
Outstanding Contributor

Re: parameter with find

Try this:

find . -name '*.HTM y *.png' -mtime +15 -exec ll

If that works and gives you the results you want, change the "ll" to "rm".


Pete

Pete
John Poff
Honored Contributor
Solution

Re: parameter with find

Hi,

I think you don't need the *.HTM after the 'll' in your second command. You'll need to use the -name option to pass the name to find, like this:

find . -mtime +15 -name "*.HTM" -exec ll {} \;

Here is one way to do it in a single command [taken from the find man page]:

find . \( -name "*.HTM" -o -name "*.png" \) -mtime +15 -exec ll {} \;

If it finds just the files you want, you can replace the 'll' with 'rm'.

JP

Sachin Patel
Honored Contributor

Re: parameter with find

pete forget the {} \; at then end.

Pete I try to run the '*.test *.out' didn't work.


Can you run two different command?
find . -name '*.HTM' -mtime +15 -exec ls -la {} \;

find . -name '*.png' -mtime +15 -exec ls -la {} \;


Sachin
Is photography a hobby or another way to spend $
LucianoCarvalho
Respected Contributor

Re: parameter with find

hi,

try this from the man page:

Remove all files named a.out or *.o that have not been accessed for a
week:

find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \;

Note that the spaces delimiting the escaped parentheses are
required.

regards
Pete Randall
Outstanding Contributor

Re: parameter with find

Sorry, I cut and paste the "*.HTM y *.png" without realizing it was two different arguments and Sachin's right, I forgot the "{} \;" (which Jairo obviously knew enough to use).

JP's got the answer - ignore my drivel.


Pete

Pete