Identifying .log files

Hi. Is there a way to:

1) produce a listing of .log files
2) older than 5 years of age
3) that includes the full path and filename together with one file per line

Any help producing such a script would be very helpful. Thanks.

try

find . -type f -name "*.log" -mtime +1825

Considering 365 day a year; i have used 1825 days for 5 years

for full path

var=`pwd`
find $var -type f -name "*.log" -mtime +1825
1 Like

Thank you. The first option seems to work, but the second gives no output. I'll try to work with the first options. I appreciate your time.

if first option is working ; second should work...
second option contains two commands...
have you ran in the same sequence

var=`pwd`

followed by

find $var -type f -name "*.log" -mtime +1825

Also you can put these both commands in one test.sh and run ./test.sh

var=`pwd`
find $var -type f -name "*.log" -mtime +1825
1 Like

Yes, I did try creating a shell script to run both commands. For whatever reason I get no ouput when running the script versus the single command. A bit perplexing. Regardless, I appreciate your help.

try

var=$(pwd)

yes for full path try with

find $(pwd) -type f -name "*.log" -mtime +1825

Use double quotes if your working directory's name has spaces in it.