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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-21-2004, 06:29 PM
|
#1
|
LQ Addict
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320
Rep:
|
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.
|
|
|
01-21-2004, 07:12 PM
|
#2
|
Senior Member
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185
Rep:
|
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 ...
|
|
|
01-21-2004, 07:40 PM
|
#3
|
LQ Addict
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320
Original Poster
Rep:
|
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.
|
|
|
01-21-2004, 07:51 PM
|
#4
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
01-21-2004, 08:00 PM
|
#5
|
LQ Addict
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320
Original Poster
Rep:
|
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.
|
|
|
01-21-2004, 08:04 PM
|
#6
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
No worries ... don't we ALL have blonde moments
once in a while? :)
Cheers,
Tink (temporary blonde)
|
|
|
01-23-2004, 06:05 PM
|
#7
|
LQ Addict
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320
Original Poster
Rep:
|
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.
|
|
|
01-24-2004, 12:42 PM
|
#8
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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) :}
|
|
|
01-24-2004, 02:32 PM
|
#9
|
LQ Addict
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320
Original Poster
Rep:
|
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.
|
|
|
01-24-2004, 08:06 PM
|
#10
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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 02:35 AM.
|
|
|
01-25-2004, 01:19 AM
|
#11
|
LQ Addict
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320
Original Poster
Rep:
|
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)
|
|
|
01-25-2004, 02:09 AM
|
#12
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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 01:05 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|