Quickzi: How To List Files with a Certain Date Stamp

Here is a quick tip on how to list files in a directory with a certain date stamp using awk.

Let’s say that you want to list all files stamped with 2008-04-11.

# ls -l | awk '{if($6=="2008-04-11") print $N }'

-rw-r--r-- 1 adam users 0 2008-04-11 16:27 file1
-rw-r--r-- 1 adam users 0 2008-04-11 16:27 file2
-rw-r--r-- 1 adam users 0 2008-04-11 16:27 file3

If you want to list only the file names, add an F switch.

# ls -l | awk '{if($6=="2008-04-11") print $NF }'
file1
file2
file3

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>