Help!

Directory listings


Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> UK RSS
Next:  [Samba] Use shares like postboxes !  
Author Message
IanW
External


Since: Jul 24, 2007
Posts: 2



PostPosted: Tue Jul 24, 2007 9:38 am    Post subject: Directory listings
Archived from groups: uk>comp>os>linux (more info?)

Hi

I want to get a directory listing from our Linux server that I can then load
into Excel, preserving columns for sorting purposes.

I'm only really interested in the filename, date and size. The nearest I've
got so far is using "ls -go" and that would be fine except for the format of
the date. Ideally I want it in dd/mm/yyyy format but it lists it like "Jun 5
2006", and even more of a hinderance is that when the file date is this year
it puts in the time instead of the year!

Had a look through the help for ls but can't seem to see anything to do with
formatting of dates. Any ideas?

Ian
Back to top
Chris
External


Since: May 27, 2005
Posts: 473



PostPosted: Tue Jul 24, 2007 9:50 am    Post subject: Re: Directory listings [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

IanW wrote:
> Hi
>
> I want to get a directory listing from our Linux server that I can then load
> into Excel, preserving columns for sorting purposes.
>
> I'm only really interested in the filename, date and size. The nearest I've
> got so far is using "ls -go" and that would be fine except for the format of
> the date. Ideally I want it in dd/mm/yyyy format but it lists it like "Jun 5
> 2006", and even more of a hinderance is that when the file date is this year
> it puts in the time instead of the year!
>
> Had a look through the help for ls but can't seem to see anything to do with
> formatting of dates. Any ideas?
>

You could try using 'find' with the -printf option. The output from
'find' is much more configurable than 'ls'.
Back to top
Robert Harris
External


Since: Aug 14, 2005
Posts: 166



PostPosted: Tue Jul 24, 2007 10:40 am    Post subject: Re: Directory listings [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

IanW wrote:
> Hi
>
> I want to get a directory listing from our Linux server that I can then load
> into Excel, preserving columns for sorting purposes.
>
> I'm only really interested in the filename, date and size. The nearest I've
> got so far is using "ls -go" and that would be fine except for the format of
> the date. Ideally I want it in dd/mm/yyyy format but it lists it like "Jun 5
> 2006", and even more of a hinderance is that when the file date is this year
> it puts in the time instead of the year!
>
> Had a look through the help for ls but can't seem to see anything to do with
> formatting of dates. Any ideas?
>
> Ian
>
>
The format of the date listing depends on your current Locale. For
example, on my system (Ubuntu), if I type:

LANG=C; ls -go

I get the same format as you, but if I type:

LANG=en_GB.utf8; ls -go

I get dates and times in ISO format, like 2006-06-05

Also on my system, which uses GNU ls, if I type:

ls -go --time-style=long-iso

I get dates and times in ISO format whatever locale is set.

"man ls" tells most of the story, as ever.

Robert
Back to top
IanW
External


Since: Jul 24, 2007
Posts: 2



PostPosted: Tue Jul 24, 2007 12:28 pm    Post subject: Re: Directory listings [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Robert Harris" <robert.f.harris.TakeThisOut@blueyonder.co.uk> wrote in message
news:FGkpi.8733$%v3.2630@fe3.news.blueyonder.co.uk...

> ls -go --time-style=long-iso
>
> I get dates and times in ISO format whatever locale is set.

That does the job nicely. Many thanks

Ian
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> UK All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum