Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

let's say there is a directory with the name 'IN'. It contain a no. of files. i wanted to know how i can find out no. of files in a folder and the earliest and latest dates on which fille has arrived in that folder.

share|improve this question

Simply do like this if you include directories.

find IN -printf "%p\t%T@\n" | sort -n -k 2 > all_files.tmp
head -n 1 all_files.tmp # for oldest
tail -n 1 all_files.tmp # for newest
wc -l all_files.tmp     # for number of files

To exclude directories,

find IN -type f -printf "%p\t%T@\n" | sort -n -k 2 > all_files.tmp

A concern is, what is the "time" you'r looking for? "mtime" is used in preceding examples. Google "atime ctime mtime" for their differences. In ext3/4 filesystems there probably no such a thing "birth time" of a file.

share|improve this answer
thanks for ur suggestion flame. actually the time here actually is the earliest date and time on which a file arrived. Lets say i have a directory in which first file arrived on 26th oct 2013 at 10:30 pm and the last arrived on 28th oct 2013. so i just need to it find out this time. – akhilesh Oct 28 '13 at 8:29
and please could u tell me what find IN -printf "%p\t%T@\n" is doing. – akhilesh Oct 28 '13 at 8:35
see manpage for what find is. "%p" for filename. "%T" for last modification time. Check you file system, and see… and… for the "creation time" issue. – Frozen Flame Oct 29 '13 at 12:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.