LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 10: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, 10: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, 10: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, 10:49 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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



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 05:30 PM
Unable to print Timestamp sowraj Linux - Newbie 3 01-29-2010 06:02 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
find all files in current folder and all subfolders and sort all by timestamp dlnlinux Linux - Newbie 2 06-03-2008 11:29 AM
can't find print manager lumba Linux - Newbie 1 01-18-2005 05:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:14 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
Open Source Consulting | Domain Registration