'find' gives different results when using -mtime with -print vs -exec
does anyone know why I'm getting different results here?
Code:
find . -mtime -2 -exec ls -lh '{}' \; | wc -l btw, the latter of the two is what I expect. What I'm going for is to find all files with an mtime of less than 2*24 hours (2 days). If it means anything... in the same dir: Code:
find . | wc -l Code:
find -version any ideas? |
For cryin' out loud. As soon as I posted the question, I thought, "I wonder if this could have anything to do with directories being listed" so I added "-type f" to the query & now we're back on track. I guess one of the things that was newer than 2*24 hours was a directory, "ls -lh" listed the whole directory along with all the other files that it found.
so, for anyone else with the same problem, be sure you're not listing subdirectories by locking in the type, i.e.: Code:
find . -mtime -2 -type f -exec ls -lh '{}' \; | wc -l |
All times are GMT -5. The time now is 09:17 PM. |