Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all files older than x days only in current directory

Tags:

bash

shell

unix

I am new to unix and couldn't get appropriate outcome in other questions.

I want to list only files in current directory which are older than x days. I have below restriction

  • List only files in current folder which are older than 30 days
  • Output shouldn't include directories and subdirectories
  • This should list files similar as "ls" command does
  • Output should look like file1 file2 file3 ..

I used find . -mtime +30. but this gives files and files in sub-directories as well. I would like to restrict doing search recursively and not to search inside directories.

Thanks a lot in advance !

like image 826
Umesh Patil Avatar asked Dec 01 '15 13:12

Umesh Patil


1 Answers

You can do this:

find ./ -maxdepth 1 -type f -mtime +30 -print

If having problems, do:

find ./ -depth 1 -type f -mtime +30 -print
like image 175
Richasantos Avatar answered Oct 11 '22 14:10

Richasantos