LinuxQuestions.org
Visit Jeremy's Blog.
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 01-21-2004, 07:29 PM   #1
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
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.
 
Old 01-21-2004, 08:12 PM   #2
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 59
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 ...
 
Old 01-21-2004, 08:40 PM   #3
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Original Poster
Rep: Reputation: 45
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.
 
Old 01-21-2004, 08:51 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

Rep: Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893
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
 
Old 01-21-2004, 09:00 PM   #5
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Original Poster
Rep: Reputation: 45
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.
 
Old 01-21-2004, 09:04 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

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


Cheers,
Tink (temporary blonde)
 
Old 01-23-2004, 07:05 PM   #7
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Original Poster
Rep: Reputation: 45
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.
 
Old 01-24-2004, 01:42 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

Rep: Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893Reputation: 893
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) :}
 
Old 01-24-2004, 03:32 PM   #9
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Original Poster
Rep: Reputation: 45
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.
 
Old 01-24-2004, 09:06 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

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

Last edited by Tinkster; 09-08-2005 at 03:35 AM.
 
Old 01-25-2004, 02:19 AM   #11
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Original Poster
Rep: Reputation: 45
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)
 
Old 01-25-2004, 03:09 AM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,000
Blog Entries: 11

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


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
mtime in find vs ls lslade Linux - Software 0 11-17-2005 02:06 PM
mtime/ctime changed on directory entries stardot Linux - Security 2 11-29-2004 11:44 PM
why does sftp change mtime file attribute? hazelhill Linux - Software 3 10-17-2004 10:42 PM


All times are GMT -5. The time now is 10:52 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration