LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-27-2010, 11:06 AM   #1
sunny8107
LQ Newbie
 
Registered: Jul 2009
Posts: 9

Rep: Reputation: 0
Question Using find to print the timestamp


All,
I am looking for a way to print the timestamp of a directory using find command. I can do that for a file, but for a directory, it is printing the contents of the directory as well.

Lets say there is a directory called doc, and there are more than one occurrences of that directory.

find . -name "doc" -type d -exec ls -l {} \;

This is printing the contents of all the files under doc directory as well. Any suggestions?

Thanks in advance!
 
Old 05-27-2010, 11:16 AM   #2
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
Code:
find . -name "doc" -type d -exec ls -ld {} \;
 
1 members found this post helpful.
Old 05-27-2010, 11:28 AM   #3
sunny8107
LQ Newbie
 
Registered: Jul 2009
Posts: 9

Original Poster
Rep: Reputation: 0
Smile

Quote:
Originally Posted by rayfordj View Post
Code:
find . -name "doc" -type d -exec ls -ld {} \;
Nice, that did it! Thanks
 
Old 05-27-2010, 11:49 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Another option is the -printf expression, e.g something like
Code:
find . -name "doc" -type d -printf "%Tc %p\n"
Using modifiers to the %T format you can customize the appearance of the timestamp.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 06:30 PM
Unable to print Timestamp sowraj Linux - Newbie 3 01-29-2010 07:02 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 06:55 PM
find all files in current folder and all subfolders and sort all by timestamp dlnlinux Linux - Newbie 2 06-03-2008 12:29 PM
can't find print manager lumba Linux - Newbie 1 01-18-2005 06:16 PM


All times are GMT -5. The time now is 04:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration