Grep for modified time

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:

is it possible to come up with a list of files that are modified before a certain number of hours only using the grep command?

ex. list files that were modified less than 10 hours ago

i've only managed to list files that were created on the same day, i can't seem to figure out how to work the time.

  1. Relevant commands, code, scripts, algorithms:

grep

  1. The attempts at a solution (include all code and scripts):
ls -ul | grep `date +%Y-%m-%d`
  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
    p.61 Bash Guide for Beginners tld.org

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

I'm not sure where you are going wrong (because you haven't shown what you actually did), but notice the difference between these on my machine:

bash-2.05a$ ls -ul | head -3
total 5377
-rw-r--r--  1 pcunix  pcunix           236367 Oct  6 14:37 h
-rw-r--r--  1 pcunix  pcunix              310 Aug 30 06:38 Girish
bash-2.05a$ ls -ul | head -4
total 5377
-rw-r--r--  1 pcunix  pcunix           236367 Oct  6 14:37 h
-rw-r--r--  1 pcunix  pcunix              310 Aug 30 06:38 Girish
-rw-r--r--  1 pcunix  pcunix             5471 Sep  5 13:59 Voila.html
bash-2.05a$ ls -ut | head -4
qa
tmp
world
wtoday
bash-2.05a$ ls -lut | head -4
total 5377
drwxr-xr-x  2 pcunix  pcunix              512 Nov 11 03:04 qa
drwxr-xr-x  2 pcunix  pcunix              512 Nov 11 03:04 tmp
drwxr-xr-x  4 pcunix  pcunix             9216 Nov 11 03:04 world
bash-2.05a$ ls -lt | head -4
total 5377
-rw-r--r--  1 pcunix  pcunix               13 Nov 10 20:42 dt
-rw-r--r--  1 pcunix  pcunix           360351 Nov 10 18:18 t
drwxr-xr-x  4 pcunix  pcunix             9216 Nov  8 21:24 world

head command shows the top lines. i need a grep command that outputs files modified in the last 10 hours. so the output could be 20 files, or none, depending on modification time.

what i've come up with narrows the files down to whatever was modified during the current day, but i can't figure out how to screen for time

mo@mo-laptop:~$ ls -ul | grep `date +%Y-%m-%d`
-rw-r--r--  1 mo mo     4045 2009-11-12 09:09 Grated Parmesan.mm
-rw-r--r--  1 mo mo    14682 2009-11-12 09:09 statusrep.mm

What TonyLawrence was getting at was that you should carefully look at the output of "ls -ul". He was using the "head"-command only to limit the output to the relevant lines.

Have a look at the various possibilities of displaying a directory entry of a file Unix uses. (Notice there are different forms of displaying the date information in older and younger files.)

"grep" filters out certain lines of some output text. Ask yourself if there is a common text pattern that sets apart all the files you are interested in and all the files you are not interested in. If there is such a thing you know you can use "grep" for the task on the premise you can construct a regular expression to cover that pattern. If there is no such thing then "grep" cannot (not even in theory) be supposed to be a suitable tool.

I hope this helps.

bakunin