Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
    
What have you tried? –  gronostaj Oct 28 '13 at 6:34
add comment

1 Answer

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 unix.stackexchange.com/questions/20460/… and unix.stackexchange.com/questions/24441/… for the "creation time" issue. –  frozen-flame Oct 29 '13 at 12:34
add comment

Your Answer

 
discard

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.