LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ls --mtime ? (https://www.linuxquestions.org/questions/linux-newbie-8/ls-mtime-137259/)

mikshaw 01-21-2004 06:29 PM

ls --mtime ?
 
I thought this would have been asked here a dozen times, but no luck in a search, so I assume I'm just blind.

in ~.bashrc i have entered
Code:

alias lsa='ls -Ahop --time-style +" %d.%b.%.%y %I:%M %p "'
and it almost gives me what I want. However, the displayed time is creation time, and I'd really prefer using modification time.

I've been up and down the ls man page and can't seem to find this option.
How is it possible to dislay mtime rather than ctime?

Another related question: can ls display directories first?

Thanks for reading.

DrOzz 01-21-2004 07:12 PM

if i am understand correctly then :
ls -ltu will work ...
it will list in ascending order the most recent date and time modified down to the oldest date /time ...

mikshaw 01-21-2004 07:40 PM

Hmmm....
this isn't really what I want. I want to be able to sort them alphabetically, yet display the modification time.
Having them sort according to mtime will just slow me down.

Thanks for your input.

Tinkster 01-21-2004 07:51 PM

Not quite sure what the problem for you is,
but in the context of ls the ctime actually
IS the last modification time.

try adding --time=ctime to your ls statment.



Cheers,
Tink

mikshaw 01-21-2004 08:00 PM

doh.....


I don't even want to admit this.......I was reading the time as a stupid american, day following month....I was wondering why most of the stuff in my home directory listed Jan04.

/me hits himself

Thanks for the help.

Tinkster 01-21-2004 08:04 PM

No worries ... don't we ALL have blonde moments
once in a while? :)


Cheers,
Tink (temporary blonde)

mikshaw 01-23-2004 06:05 PM

Found an answer to the second question:
alias lsal='ls -Ahop --time-style +" %d.%b.%y %I:%M %p " | grep /; ls -Ahop --time-style +" %d.%b.%y %I:%M %p " | grep -v /'

It just does two lists, one for directories only, and one for everything excluding directories.

Tinkster 01-24-2004 12:42 PM

Just out of curiosity:

Why that 'strange' format for the date & time? :)

long-iso would be 'easier' to write, and would
allow for sensible sorting if you needed to post-
process the output...


Cheers,
Tink (with an aversion against American time format) :}

mikshaw 01-24-2004 02:32 PM

Dunno...it doesn't seem strange to me. This is what the output looks like:
Code:

-rw-------  1 mik    35K  05.Jan.04  09:00 PM  .xsession-errors
I haven't tried long-iso though....there's a good chance it may work just as well.

Tinkster 01-24-2004 08:06 PM

Quote:

Dunno...it doesn't seem strange to me.
Well, I've been using ISO style dates and
24 hour times for too long I guess... :)

Code:

drwxr-xr-x    2 tink    users          48 2003-09-03 20:29 zeosdbo
Just makes sorting a breeze, and to me
is second nature ...


Cheers,
Tink

mikshaw 01-25-2004 01:19 AM

Yes, sorting would be much easier that way. I haven't become accustomed to viewing 24-hour time though....I always have to subtract 12 from the latter numbers to figure out what time it is =o)

Tinkster 01-25-2004 02:09 AM

Looking at the WHOLE time, date & time,
it's also easier and more consistent... :)


Cheers,
Tink


All times are GMT -5. The time now is 09:06 AM.