The ls command has a couple of switches here that might accomplish what you are looking for. After reading this, do a man ls on whatever flavor of Unix you are using in case the exact letter used for the switch is different.
First, ls -lc will usually give you a timestamp of when the file was last modified.
Secondly, ls -lu will usually give you a timestamp of when the file was last accessed.
So, if a file has been created and never accessed (and hence never modified), an ls -lu command will report the timestamp of when the file was created. But the next time you access the file, that timestamp is updated.
Now, if you are trying to figure out which files are older than other files, you could try this:
ls -lct /directory
-l --> Gives the long listing, which includes the timestamp
-c --> Gives a timestamp of when the file was last written to
-t --> sorts the output so that the files most recently modified are at the top and the older modification times are at the bottom.
So, combining all of this with what I've gathered from your other posts:
from your home directory:
grep <whatever it is your looking for> /directory/of/*.dbf > somefile
Now, if you did a more on somefile the entry will probably look like this:
<the name of the file containing the string>:<the string you searched for>
Now, you want to get information on that file. If there are only a handful of lines, you could open somefile in
vi and manually delete everything after the colon, which just leaves the filename. But, if you end up with dozens or even hundreds of entries, we need a more efficient way to parse out the filename.
awk -F: '{print $1}' somefile > somefile2
mv somefile2 somefile
We now have a list of all files in the /directory/of/*.dbf that match the string you wanted. Now to get information on those files.
for filename in `cat somefile`
do
ls -lc $filename >> somefile2
done
mv somefile2 somefile
Finally, more somefile.
** You'll note in my for loop I did not use the -t flag on the ls command. Since we're getting info on files one at a time, their really isn't a way to sort them here. Once we get all the output into a text file, you could use awk and sort to put them in order if you needed. **
It kinda long and ugly, but from what you told me this should get the job done.
Did this answer your question or did I go WAAAYYYY out in left field?
- HK