Check file created is less than 4 hours or not.

I don't know how "date" and "ls" work on HP-UX, but the solution I offered is at least a clue.

ls -l --time-style=long-iso

this will produce a list of lines in which the create time of files appear in a form of "2010-04-15 16:27"(on column 6 and 7 in my case), which can be compared with that produced by

date +"%Y-%m-%d %R" --date="240 minutes ago"

You may just modify the one liner and get it work for your situation.

I have modified the one liner a little bit. I test it on RHEL and Cygwin, and it works as expected:

ls -l --time-style=long-iso | awk ' BEGIN { "date +\"%Y-%m-%d %R\" --date=\"240 minutes ago\"" | getline minutes } $6" "$7 >= minutes { print $NF } '

Good luck.

Hi kevintse,

I am getting error while using that command in Sun Solaris. Is there any equivalent command for this in Sun OS.

> ls -l --time-style=long-iso
ls: illegal option -- -
ls: illegal option -- e
ls: illegal option -- -
ls: illegal option -- y
ls: illegal option -- e
ls: illegal option -- =
ls: illegal option -- -
usage: ls -1RaAdCxmnlogrtucpFbqisfL [files]

Thanks,
Sameer.