It is the alternative way of searching for things in UNIX grep is another Linux command which provides similar functionality like find but in my opinion, later is much more potent than grep in UNIX.
If you are a QA, support personnel, and your works involve lots of searching text on Linux machine or if you are a Java or C++ programmer and your code resides in UNIX, find command can significantly help you to look for any word inside your source file in the absence of an IDE. I believe having a good knowledge of find command in UNIX and understanding of its different options and usage will increase your productivity a lot in UNIX based operating systems, e.g. Join the nixCraft community via RSS Feed, Email Newsletter or follow on Twitter.The find command is one of the most versatile commands in UNIX and Linux, and I used it a lot in my day-to-day work. He wrote more than 7k+ posts and helped numerous readers to master IT topics. Vivek Gite is the founder of nixCraft, the oldest running blog about Linux and open source. See -atime and -mtime FAQ for more information.type f -newerat ! -newerat -ls List all *.c file accessed 30 days agoįind /home/you -iname "*.c" -atime -30 -type fįind /home/you -iname "*.c" -atime -30 -type f -ls List all *.c file accessed more than 30 days agoįind /home/you -iname "*.c" -atime +30 -type fįind /home/you -iname "*.c" -atime +30 -type f -ls List all *.c file accessed exactly 30 days agoįind /home/you -iname "*.c" -atime 30 -type fįind /home/you -iname "*.c" -atime 30 -ls See also: init.d/.depend.stop To see all files accessed on the 25/Sep/2017: # pass the -ls option to list files in ls -l format #ĩ56 4 -rw-r-r- 1 root root 910 Sep 24 11: 42.
To see all files modified on the 24/Sep/2017 in the current directory: t – reference is interpreted directly as a time.m – The modification time of the file reference.c – The inode status change time of reference.B – The birth time of the file reference.a – The access time of the file reference.The letters X and Y can be any of the following letters: Say hello to -newerXY option for find commandįind /dir/ -type f -newerXY 'yyyy-mm-dd' -ls
Gnu find as various command line option to list files by a modification and access date/time stamp. You can save list to a text file called output.txt as follows:įind /data/images -type f -newer /tmp/start -not -newer /tmp/end > output.txt Linux find file by date using the date command In this example find files modified between Jan/1/2007 and Jan/1/2008, in /data/images directory:įind /data /images -type f -newer /tmp /start -not -newer /tmp /end If you need a specific date range many days ago, than consider using the find command. You need to use the grep command/ egrep command to filter out info:Ī better and recommended solution is the find command:įind /etc/ -type f -ls |grep '25 Sep' find Command Example rw-r-r- 1 root root 703 nfĭrwxr-xr-x 2 root root 4096 rw-r-r- 1 root root 477 zsh_command_not_found Drwxr-xr-x 2 root root 4096 Sep 24 11: 42 sysctl.dĭrwxr-xr-x 2 root root 4096 Sep 24 11: 42 logrotate.dĭrwxr-xr-x 2 root root 4096 Sep 24 11: 42 initĭrwxr-xr-x 2 root root 4096 Sep 24 11: 42 init.dĭrwxr-xr-x 2 root root 4096 Sep 24 11: 42 dnsmasq.d-availableĭrwxr-xr-x 2 root root 4096 Sep 23 06: 22 bash_completion.d