LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-04-2017, 07:38 AM   #1
krazybob
Member
 
Registered: Oct 2009
Location: Los Angeles, CA
Distribution: Centos 5.x
Posts: 133

Rep: Reputation: 3
Finding files created after 01-01-2017


For the life of me I cannot remember the command to find files created in the year 2017. I know that there are numerous was but as I recall it was a 'find' command and possibly used '-mtime'.

Thanks in advance.
 
Old 07-04-2017, 08:20 AM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,016
Blog Entries: 5

Rep: Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862
Entering linux find files year in Google Search returns the following page:

https://unix.stackexchange.com/quest...-based-on-year

which suggests:

Quote:
find /media/WD/backup/osool/olddata/ -newermt 20120101 -not -newermt 20130101
for 2012 (modify as necessary).
 
Old 07-04-2017, 09:03 AM   #3
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 4,177
Blog Entries: 3

Rep: Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067
The specifics for that would be in the manual page for find under -newerXY. In the above example, X is m to check the modification time and Y is t to reference a time string.

Code:
man find
 
Old 07-04-2017, 05:44 PM   #4
krazybob
Member
 
Registered: Oct 2009
Location: Los Angeles, CA
Distribution: Centos 5.x
Posts: 133

Original Poster
Rep: Reputation: 3
This is on CentOS 6.9 and fails.

Quote:
find: invalid predicate `-newermt'
Quote:
man find
is of little help to a newbie... I've already scoured Google and cannot find the prior solutons.
 
Old 07-04-2017, 05:58 PM   #5
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,016
Blog Entries: 5

Rep: Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862
Entering find invalid predicate in Google Search returns the following page:

https://stackoverflow.com/questions/...-using-newermt

which suggests that your operating system may not support -newermt, in which case you can use -newer and compare the dates against two files for which you have set the modification dates.
 
Old 07-04-2017, 06:54 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,670

Rep: Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487
Just a minor point, but *nix filesystems don't (usually) store create date
Quote:
Three fields in the inode structure contain the last access, change, and modification times: atime, ctime, and mtime. The atime field is updated each time the pointer to the file's data blocks is followed and the file's data is read. The mtime field is updated each time the file's data changes. The ctime field is updated each time the file's inode changes. The ctime is not creation time; there is no way under standard Unix to find a file's creation time.
Perl Cookbook

The 'find' cmd allows you to specify which one you want to use.
 
Old 07-04-2017, 07:11 PM   #7
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 19.1 MATE
Posts: 8,016
Blog Entries: 5

Rep: Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862Reputation: 2862
Quote:
Originally Posted by chrism01 View Post
Just a minor point, but *nix filesystems don't (usually) store create date.
Just to add some info, the ext4 filesystem's extended inodes do include crtime, which stores the file creation time.
 
Old 07-04-2017, 11:48 PM   #8
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 4,177
Blog Entries: 3

Rep: Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067
Quote:
Originally Posted by krazybob View Post
This is on CentOS 6.9 and fails.

Quote:
man find
is of little help to a newbie...
Right. But it is of some help, and the goal is to move forward even if in small steps. What did the manual page show in regards to -newerXY for your CentOS 6.x? Your choices are limited to what the documentation on your machine shows.

If -newer is the only such option, then you'll have to touch two files with custom dates and then use -newer and \! -newer instead.

Code:
touch --date=20170601 start.foobar
touch --date=20170630 end.foobar

find /some/dir/ -type f -newer start.foobar \! -newer end.foobar -print
The backslash \ is there to escape the exclation mark ! so that it is passed to find instead of being processed by the shell. In the shell it is a special symbol that would cause other actions to be taken.
 
Old 07-04-2017, 11:59 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,670

Rep: Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487
Re crtime on ext4 (only); yeah, also known as birthtime . See eg https://unix.stackexchange.com/quest...-empty-on-ext4 for a way of getting it.

AFAIK, very few if any std utils currently set or read this:
https://moiseevigor.github.io/softwa...nux-with-ext4/
 
Old 07-05-2017, 05:38 AM   #10
krazybob
Member
 
Registered: Oct 2009
Location: Los Angeles, CA
Distribution: Centos 5.x
Posts: 133

Original Poster
Rep: Reputation: 3
But this server is a EXT3 system. I appreciate the help by man find is as helpful as telling a blind man that the 7-11 down on the corner on the left. Maybe he can smell the nachos. Bad example but hopefully you get my point.

I was once a prolific programmer. But with Linux and the plethora of command line switches make learning a struggle for me. Which ones work with others? Etc. I'm struggling. My newest server using Centos 6.9. I am trying to clean out all of the sites that have been hacked and used to build websites within web sites. Alibaba. They hide files everywhere.
 
Old 07-05-2017, 05:47 AM   #11
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 4,177
Blog Entries: 3

Rep: Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067
Quote:
Originally Posted by krazybob View Post
Which ones work with others?
That's what the manual pages are for. They are how you navigate the system. They are references to look up stuff in and are terse as references should be.

Quote:
Originally Posted by krazybob View Post
Etc. I'm struggling. My newest server using Centos 6.9. I am trying to clean out all of the sites that have been hacked and used to build websites within web sites. Alibaba. They hide files everywhere.
Sorry to hear that. Yes, once they are in they can and do hide files everywhere. Figure out how they got in ...

But once they have gotten in you have one option and one option only: backup your data again, backup your logs, reformat and do a fresh but locked down install of CentOS. What kind of recovery plan do you have on file?
 
Old 07-05-2017, 09:10 AM   #12
krazybob
Member
 
Registered: Oct 2009
Location: Los Angeles, CA
Distribution: Centos 5.x
Posts: 133

Original Poster
Rep: Reputation: 3
This works

Code:
touch --date "2017-12-01" /tmp/start
touch --date "2017-12-31" /tmp/end
find . -type f -newer /tmp/start -not -newer /tmp/end
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync problems due to dot files (.*.ext) from Mac OSX created files rjo98 Linux - Server 11 03-29-2013 01:19 PM
finding files that were created before a certain date basher400 Linux - Newbie 2 06-16-2009 02:46 AM
Is there any other way of finding out if my file is just modified or is newly created deepti Linux - General 3 01-07-2009 10:35 PM
Finding files and then finding content within those files... Maeltor Linux - Software 5 03-13-2007 12:06 PM
find command : finding files that are created within last 24 hours Fond_of_Opensource Linux - Newbie 1 11-06-2006 03:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration