Operating System - HP-UX
1836323 Members
2075 Online
110100 Solutions
New Discussion

Re: File Listing with Date/Time Rephrase.

 
SOLVED
Go to solution

File Listing with Date/Time Rephrase.

re: message below
Thanks for the replies but I'm not sure I was being clear enough. My user typically uses ll for getting time and date stamps on his output. Is there not a command, or combination of commands, that will list all files with date and time ?

Thanks again !
It's much appreciated!

Sincerely,
Pam Goodwin

Original Note Below --------------------

I'm hoping someone here can help me. I've got a user who's trying to list files in a directory but he requires the output to include a file's eight digit create date and 4-6 digit time stamp. Is this possible? I could not find any command which returned this information. Any guidance you could give me would be greatly appreciated.

Thank You In Advance,
Sincerely and Respectfully,
Pamela Goodwin
UNIX Systems Admin
"...it's turtles all the way down."
9 REPLIES 9
Dan Hetzel
Honored Contributor

Re: File Listing with Date/Time Rephrase.

Hi Pamela,

Most probably because you're new in this forum, you didn't know that you should "reply" to your own question if you want to clarify something instead of starting a new thread.
No problem, but hitting the "reply" button will help all of us as all relevant info is in the same thread.

Back to your problem:

'ls -lR' will recursively list all directories
dont type 'ls -lR /' as this will take a LONG time ;-)

another way of listing files in a tree is with using 'find', like this:
find /$where_from -type f -exec ll {} \;
note the escaped semicolon, it's needed !
replace $where_from with the top directory name from which you want to search for files.

You can even refine your 'find', using flags like -mtime or -atime for example:
find /$where_from -type f -mtime +7 -exec ll {} \;
will list all files who have been modified more than a week ago.

Have a look at manpage for 'find'. You'll surely discover something in there.

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com

Re: File Listing with Date/Time Rephrase.

Dan - Yes, I am new here. Sorry for the rookie mistake. Thanks for the info you supplied. What I'm looking for though, doesn't appear to be addressed. I need the current date AND time of each file. Is there some command/combo that will give me BOTH the date and time of the file? Not necessarily the create date, but the most recent date/time (ie. create or modify).

Thanks in Advance.
~ Pam

"...it's turtles all the way down."
Pete Ellis
Trusted Contributor

Re: File Listing with Date/Time Rephrase.

Pamela,

If I understand your question, the problem is that the ll or ls -l commands do not show the time for files older than 6 months but show the year - and files that show the time do not show the year.
Also you would like the date and time in a YYYYMMDD HHMM format.
If this is so, then this would be best done with perl, but my perl is not that good, a search on the forum for perl and date would give you lots of examples!
Dan Hetzel
Honored Contributor

Re: File Listing with Date/Time Rephrase.

Hi Pam,

The problem is that 'ls' and 'll' will only give the time if the date is less than 6 months old. Otherwise, only the date is given.

There was another post this morning where a similar question was asked and a perl script was given. I didn't check the script.

Here is the link:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x51b5854994d9d4118fef0090279cd0f9,00.html

Best regards,

Dan
Everybody knows at least one thing worth sharing -- mailto:dan.hetzel@wildcroft.com

Re: File Listing with Date/Time Rephrase.

Dan and Pete -

Thanks very much for taking the time to respond. It's appreciated.

All The Best,
~ Pam
"...it's turtles all the way down."
James R. Ferguson
Acclaimed Contributor
Solution

Re: File Listing with Date/Time Rephrase.

Hi Pam:

There is a "super ls" available from the porting archive. It's man page notes that, "sls is a program designed to overcome the limitations of the standard UNIX ls(1) program, providing a more consistent interface to file inode information. It is particularly designed for use by shell scripts...". You might find this of interest.

http://hpux.cs.utah.edu/hppd/hpux/Shells/sls-1.0/man.html

...JRF...

Re: File Listing with Date/Time Rephrase.

JRF - WooWhoo ! That looks like it will give my guy the info he needs. Can't thank you enough for your attention.

Actually, thanks to everyone.

All The Best,
Sincerely and Respectfully,
~ Pam Goodwin
"...it's turtles all the way down."
James R. Ferguson
Acclaimed Contributor

Re: File Listing with Date/Time Rephrase.

Hi Pam:

I'm glad to have helped. Your most welcome!!!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: File Listing with Date/Time Rephrase.

Hi:

OOPS! "your" (sic) "you're" !!! -> Paula C. would have my US-English hide. ;-)

...JRF...