Hi Tim,

>      find /var/log/ -name '*.log*' -type f -mtime +7 -print
...
> -rwxrwxr-x 1 mit mit 104 Apr 22 21:29 deletefile.sh

Does ‘sudo ./deletefile.sh’ — or similar, if it's not in the current
directory — now work?

> So now for a second question -name '*log*' I assume that this looks for 
> a file name with log in it regardless of where in the name it finds 
> logs

Yes, find's ‘globbing’ has ‘*’ match zero or more characters.

> so it will select "file.log" as well as "file.log.2.gz".

Yes.

> The reason I ask it that it is selecting some compressed log files like 
> file.log.2.gz but ignoring other which are like 5 weeks old.

- Your script above has ‘*.log*’, not ‘*log*’.
- Give an example path name of what it is ignoring.

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2025-05-06 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  https://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to