Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Before I begin please assume I have only basic knowledge in UNIX. Basic meaning I have only started reading about it since last week for a work related purpose.

I have been experimenting with the ls command to provide lists of a particular directory containing video media. I needed to display the filename, filesize and the date it was created. I achieved this by using the command:

ls -gohU

This was fine but the search also included the sub-directories within this directory. After searching I found another command which displays the files and excludes the folders:

find . -maxdepth 1 -not -type d

What I would like to know is if there is a command that can find all files within the directory excluding sub-directories and display their filenames, size and the date they were created.

P.S. I am also using Terminal - bash on Mac OS 10.6.8 if that helps.

share|improve this question
    
fwiw Filesystems other than ext4 don't generally record file creation time (I believe this includes HFS+). Bear that in mind when you're interpreting the date. "mtime" is time of last file modification "ctime" is the last time the metadata changed and "atime" is the last access time. –  Bratchley Apr 9 '13 at 16:20

4 Answers 4

Use the -exec option to combine both the commands that work for you:

find . ! -name . -prune ! -type d -exec ls -gohU {} +
share|improve this answer

If first character is d then a file is directory. To list lines beginning with other characters use:

ls -gohU | grep '^[^d]'
share|improve this answer
    
Thank you very much, I found this method to work best for what I wanted displayed. I'm very grateful –  user36833 Apr 9 '13 at 15:54

Alternative to ls if you only want some fields is OS/X's stat command:

find . ! -name . -prune ! -type d -exec stat -t '%FT%T' -f '%15z %SB %N' {} +

Or with zsh:

command stat -t '%FT%T' -f '%15z %SB %N' -- *(D^/)

(%B, ls -U are OS/X specific, other Unices generally don't have inode birth times).

share|improve this answer

Most versions of find support -ls option so the following should give you what you're going for:

find . -maxdepth 1 -type f -ls
share|improve this answer

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.