file date stamp

i am trying to get the file modification TIME (hh:mm) for files which
were created more than 6 months ago. however, when doing a "ls"
command, files which were created more than 6 months ago do not show
the TIME but rather the YEAR. for example:

-rw-r--r-- 1 fred 17727 Jan 19 2005 1.txt
-rw-r--r-- 1 fred 45116 Jan 19 2005 2.txt
-rw-r--r-- 1 fred 42858 Jan 20 2005 3.txt
-rw-r--r-- 1 fred 115713 Jan 21 2005 4.txt
-rw-r--r-- 1 fred 101056 Jan 22 15:22 5.txt
-rw-r--r-- 1 fred 19529 Jan 24 17:29 6.txt
-rw-r--r-- 1 fred 38632 Jan 24 23:01 7.txt
-rw-r--r-- 1 fred 48671 Jan 25 20:39 8.txt
-rw-r--r-- 1 fred 48593 Jan 26 19:59 9.txt

file "4.txt" has a file modification time of "Jan 21 2005". instead of
"2005", i really want the hour and minute. is there anyway to obtain
this?
fredflinstonebogus [ Do, 21 Juli 2005 18:08 ] [ ID #888018 ]

Re: file date stamp

fredflinstonebogus [at] yahoo.com wrote:

> i am trying to get the file modification TIME (hh:mm) for files which
> were created more than 6 months ago. however, when doing a "ls"
> command, files which were created more than 6 months ago do not show
> the TIME but rather the YEAR. for example:
>
> -rw-r--r-- 1 fred 17727 Jan 19 2005 1.txt
> -rw-r--r-- 1 fred 45116 Jan 19 2005 2.txt
> -rw-r--r-- 1 fred 42858 Jan 20 2005 3.txt
> -rw-r--r-- 1 fred 115713 Jan 21 2005 4.txt
> -rw-r--r-- 1 fred 101056 Jan 22 15:22 5.txt
> -rw-r--r-- 1 fred 19529 Jan 24 17:29 6.txt
> -rw-r--r-- 1 fred 38632 Jan 24 23:01 7.txt
> -rw-r--r-- 1 fred 48671 Jan 25 20:39 8.txt
> -rw-r--r-- 1 fred 48593 Jan 26 19:59 9.txt
>
> file "4.txt" has a file modification time of "Jan 21 2005". instead of
> "2005", i really want the hour and minute. is there anyway to obtain
> this?
>

Take a look at the GNU "stat" and "find" man pages.

Regards,

Ed.
Ed Morton [ Do, 21 Juli 2005 20:51 ] [ ID #888019 ]

Re: file date stamp

On Thu, 21 Jul 2005 09:08:35 -0700, fredflinstonebogu wrote:

>
> i am trying to get the file modification TIME (hh:mm) for files which
> were created more than 6 months ago. however, when doing a "ls"
> command, files which were created more than 6 months ago do not show
> the TIME but rather the YEAR. for example:

[...]

> -rw-r--r-- 1 fred 115713 Jan 21 2005 4.txt
> -rw-r--r-- 1 fred 101056 Jan 22 15:22 5.txt

[...]

> file "4.txt" has a file modification time of "Jan 21 2005". instead of
> "2005", i really want the hour and minute. is there anyway to obtain
> this?

From man ls:
--full-time
list both full date and full time

For the filtering on age, check out the -mtime option of find.


HTH, HAND


mvg,
Guus
GH Snijders [ Do, 21 Juli 2005 21:45 ] [ ID #888020 ]

Re: file date stamp

On 2005-07-21, GH Snijders wrote:
> On Thu, 21 Jul 2005 09:08:35 -0700, fredflinstonebogu wrote:
>
>>
>> i am trying to get the file modification TIME (hh:mm) for files which
>> were created more than 6 months ago. however, when doing a "ls"
>> command, files which were created more than 6 months ago do not show
>> the TIME but rather the YEAR. for example:
>
> [...]
>
>> -rw-r--r-- 1 fred 115713 Jan 21 2005 4.txt
>> -rw-r--r-- 1 fred 101056 Jan 22 15:22 5.txt
>
> [...]
>
>> file "4.txt" has a file modification time of "Jan 21 2005". instead of
>> "2005", i really want the hour and minute. is there anyway to obtain
>> this?
>
> From man ls:
> --full-time
> list both full date and full time

Only with the GNU version.

If you have the GNU utilities, there is stat, which allows a
format string describing the information you want printed. There
is a similar utility on *BSD; the name is the same, but the syntax
is different.

Also, the GNU date program can print the timestamp, formatted as
you like, from a file with the -r option:

$ ls -l 4711c07_toAR.doc
-rw-rw-r-- 1 chris 1000 62976 Jan 10 2005 4711c07_toAR.doc
$ date -r 4711c07_toAR.doc "+%Y-%m-%d %H:%M:%S"
2005-01-10 23:05:21
$ stat -c "%y" 4711c07_toAR.doc
2005-01-10 23:05:21.000000000 -0500


--
Chris F.A. Johnson <http://cfaj.freeshell.org>
============================================================ ======
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>
cfajohnson [ Do, 21 Juli 2005 21:59 ] [ ID #888021 ]

Re: file date stamp

fredflinstonebogus [at] yahoo.com wrote:
> i am trying to get the file modification TIME (hh:mm) for files which
> were created more than 6 months ago. however, when doing a "ls"
> command, files which were created more than 6 months ago do not show
> the TIME but rather the YEAR. for example:
>
> -rw-r--r-- 1 fred 17727 Jan 19 2005 1.txt
> -rw-r--r-- 1 fred 45116 Jan 19 2005 2.txt
> -rw-r--r-- 1 fred 42858 Jan 20 2005 3.txt
> -rw-r--r-- 1 fred 115713 Jan 21 2005 4.txt
> -rw-r--r-- 1 fred 101056 Jan 22 15:22 5.txt
> -rw-r--r-- 1 fred 19529 Jan 24 17:29 6.txt
> -rw-r--r-- 1 fred 38632 Jan 24 23:01 7.txt
> -rw-r--r-- 1 fred 48671 Jan 25 20:39 8.txt
> -rw-r--r-- 1 fred 48593 Jan 26 19:59 9.txt
>
> file "4.txt" has a file modification time of "Jan 21 2005". instead of
> "2005", i really want the hour and minute. is there anyway to obtain
> this?
>

perl can do it:

\ls | perl -ne \
'chop; [at] x=lstat "$_"; printf "%s %s\n",scalar localtime $x[9],$_;'

--
Michael Tosch [at] hp : com
Michael Tosch [ Do, 21 Juli 2005 22:07 ] [ ID #888022 ]

Re: file date stamp

In comp.unix.shell Chris F.A. Johnson <cfajohnson [at] gmail.com>:
> On 2005-07-21, GH Snijders wrote:
>> On Thu, 21 Jul 2005 09:08:35 -0700, fredflinstonebogu wrote:
>>
>>>
>>> i am trying to get the file modification TIME (hh:mm) for files which
>>> were created more than 6 months ago. however, when doing a "ls"
[..]

>>> file "4.txt" has a file modification time of "Jan 21 2005". instead of
>>> "2005", i really want the hour and minute. is there anyway to obtain
>>> this?
>>
>> From man ls:
>> --full-time
>> list both full date and full time

> Only with the GNU version.

The culprit about the OP, there's no mention about which *nix is
used so we don't know.

> If you have the GNU utilities, there is stat, which allows a
> format string describing the information you want printed. There
> is a similar utility on *BSD; the name is the same, but the syntax
> is different.

> Also, the GNU date program can print the timestamp, formatted as
> you like, from a file with the -r option:

Perhaps more portable (untested) but time consuming:

tar -cf - file | tar -tvf -

[..]

--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo zvpunry [at] urvzvat.qr | perl -pe 'y/a-z/n-za-m/'
#bofh excuse 442: Trojan horse ran out of hay
Michael Heiming [ Do, 21 Juli 2005 22:17 ] [ ID #888023 ]

Re: file date stamp

On Thu, 21 Jul 2005 13:51:39 -0500, Ed Morton
<morton [at] lsupcaemnt.com> wrote:
>
>
> fredflinstonebogus [at] yahoo.com wrote:
>
>> i am trying to get the file modification TIME (hh:mm) for files which
>> were created more than 6 months ago. however, when doing a "ls"
>> command, files which were created more than 6 months ago do not show
>> the TIME but rather the YEAR. for example:
>>
>> -rw-r--r-- 1 fred 17727 Jan 19 2005 1.txt
>> -rw-r--r-- 1 fred 45116 Jan 19 2005 2.txt
>> -rw-r--r-- 1 fred 42858 Jan 20 2005 3.txt
>> -rw-r--r-- 1 fred 115713 Jan 21 2005 4.txt
>> -rw-r--r-- 1 fred 101056 Jan 22 15:22 5.txt
>> -rw-r--r-- 1 fred 19529 Jan 24 17:29 6.txt
>> -rw-r--r-- 1 fred 38632 Jan 24 23:01 7.txt
>> -rw-r--r-- 1 fred 48671 Jan 25 20:39 8.txt
>> -rw-r--r-- 1 fred 48593 Jan 26 19:59 9.txt
>>
>> file "4.txt" has a file modification time of "Jan 21 2005". instead of
>> "2005", i really want the hour and minute. is there anyway to obtain
>> this?
>>
>
> Take a look at the GNU "stat" and "find" man pages.
>
Or, if you have the GNU version of ls, "ls --full-time".

--
Tonight you will pay the wages of sin; Don't forget to leave a tip.
Bill Marcum [ Do, 21 Juli 2005 22:26 ] [ ID #888025 ]

Re: file date stamp

thanks for all the suggestions. The Unix OS version I am using is
Tru64 OSF1 V4.0F. I'm not so quick with C or perl, so if anyone can
provide me a Unix command(s) that I can just type at the prompt, that
would be easiest for me, if it is possible.
fredflinstonebogus [ Do, 21 Juli 2005 22:40 ] [ ID #888026 ]

Re: file date stamp

On 2005-07-21, fredflinstonebogus [at] yahoo.com wrote:
> thanks for all the suggestions. The Unix OS version I am using is
> Tru64 OSF1 V4.0F. I'm not so quick with C or perl, so if anyone can
> provide me a Unix command(s) that I can just type at the prompt, that
> would be easiest for me, if it is possible.

What was wrong with the suggestions you have received?



Please quote enough of the post you are replying to to give the
context of your own post. This is Usenet, not a web forum (though
it is also bastardized on several web sites, including Google
groups).

"If you want to post a followup via groups.google.com, don't
use the broken "Reply" link at the bottom of the article.
Click on "show options" at the top of the article, then click
on the "Reply" at the bottom of the article headers."
- Keith Thompson
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
============================================================ ======
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>
cfajohnson [ Do, 21 Juli 2005 23:09 ] [ ID #888027 ]

Re: file date stamp

Some OS's support a handy option in find, try:
`find . -ls .

JB
johngnub [ Do, 21 Juli 2005 23:23 ] [ ID #888031 ]

Re: file date stamp

In comp.unix.shell fredflinstonebogus [at] yahoo.com:
> thanks for all the suggestions. The Unix OS version I am using is
> Tru64 OSF1 V4.0F. I'm not so quick with C or perl, so if anyone can
> provide me a Unix command(s) that I can just type at the prompt, that
> would be easiest for me, if it is possible.

Well, it looks like you already got two commands which should do
the trick (hopefully).

tar -cf - * | tar -tvf -

\ls | perl -ne \
'chop; [at] x=lstat "$_"; printf "%s %s\n",scalar localtime $x[9],$_;'
(Michael Tosch)

It's up to you testing them out. There have been additional GNU
software CDs available containing most GNU software others
mentioned in this thread, for 4.0F. Dunno if you can still get
them, if you are authorized to install things?

Good luck

BTW
You are replying from google groups in its default way which does
not quote the text you are replying to. This makes it harder for
people not using google groups to help you, while at the same
time annoying regulars on a daily basis. IIRC there is an option
to show text and then you can use the reply button at the bottom.

--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo zvpunry [at] urvzvat.qr | perl -pe 'y/a-z/n-za-m/'
#bofh excuse 239: CPU needs bearings repacked
Michael Heiming [ Do, 21 Juli 2005 23:23 ] [ ID #888032 ]

Re: file date stamp

> Well, it looks like you already got two commands which should do
> the trick (hopefully).
>
> tar -cf - * | tar -tvf -

thanks. this one worked quite well. another person earlier had also
suggested this, but I was afraid to try it because i thought it was
going to tar up my files.


> \ls | perl -ne \
> 'chop; [at] x=lstat "$_"; printf "%s %s\n",scalar localtime $x[9],$_;'
> (Michael Tosch)

i tried this one, but perl is not installed on my machine.


> You are replying from google groups in its default way which does
> not quote the text you are replying to. This makes it harder for
> people not using google groups to help you, while at the same
> time annoying regulars on a daily basis. IIRC there is an option
> to show text and then you can use the reply button at the bottom.

sorry to annoy everyone. hope i did it right this time. my office
mate just clued me in on a newsgroup program i should use instead of
google. thanks for all the help. this is great to have the help of
others. happy friday.
fredflinstonebogus [ Fr, 22 Juli 2005 15:21 ] [ ID #889737 ]

Re: file date stamp

fredflinstonebogus [at] yahoo.com wrote:
>>Well, it looks like you already got two commands which should do
>>the trick (hopefully).
>>
>> tar -cf - * | tar -tvf -
>
>
> thanks. this one worked quite well. another person earlier had also
> suggested this, but I was afraid to try it because i thought it was
> going to tar up my files.
>

It does tars all file data into the pipe buffer.
This is a temporary buffer in memory only, but if your files are many
GB big, the many GB will transfer to memory, while you only want some
meta-data.
Nevertheless, the tar solution is ok if you dont run this often and if
you have small files.

The perl code (and all solutions with "stat") only reads the meta-data:

>
>
>> \ls | perl -ne \
>>'chop; [at] x=lstat "$_"; printf "%s %s\n",scalar localtime $x[9],$_;'
>>(Michael Tosch)
>
>
> i tried this one, but perl is not installed on my machine.
>

Download perl from e.g.
http://www.tru64.org/pages.php?page=Software


--
Michael Tosch [at] hp : com
Michael Tosch [ Fr, 22 Juli 2005 18:50 ] [ ID #889748 ]
Linux » comp.unix.shell » file date stamp

Vorheriges Thema: Sort question
Nächstes Thema: Meaning of ${2:+ +/$2}