Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ls questions from a noob...
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
ClippyHater
Apprentice
Apprentice


Joined: 06 Nov 2002
Posts: 247
Location: Wisconsin

PostPosted: Sun Mar 16, 2003 2:30 am    Post subject: ls questions from a noob... Reply with quote

Can someone point me to info on
how to have ls always use colors
and to sort by alpha descending
order, but with directories listed
first (all directories in alpha
order) followed by links then
followed by files? I'd like to be
able to do this *without* typing
anything other than 'ls'...

Thanks!
Back to top
View user's profile Send private message
evidence
Tux's lil' helper
Tux's lil' helper


Joined: 04 Nov 2002
Posts: 85

PostPosted: Sun Mar 16, 2003 3:57 am    Post subject: Reply with quote

Copy the .bashrc and .bash_profile from /etc/skel/ into your home directory. Then take a look at .bashrc. It will already have aliases that will do the type of thing you describe. Or if you want ls to do more, you can create your own aliases and put them in .bashrc
Back to top
View user's profile Send private message
ClippyHater
Apprentice
Apprentice


Joined: 06 Nov 2002
Posts: 247
Location: Wisconsin

PostPosted: Sun Mar 16, 2003 12:16 pm    Post subject: Reply with quote

Thanks!
Back to top
View user's profile Send private message
ClippyHater
Apprentice
Apprentice


Joined: 06 Nov 2002
Posts: 247
Location: Wisconsin

PostPosted: Sun Mar 16, 2003 1:58 pm    Post subject: Reply with quote

Ok, things are working great with copying those two files... but I've looked through man ls, and couldn't find a way to sort directories first. Anyone have an idea of how to do this?
Back to top
View user's profile Send private message
jfb3
Apprentice
Apprentice


Joined: 01 Feb 2003
Posts: 242

PostPosted: Mon Mar 17, 2003 9:28 am    Post subject: Here's a first draft Reply with quote

While there are some patches I've seen to ls to accomplish this I haven't tried them yet. So, to tide you over here is at leas some info:

ls -l |grep ^d
gives you only the directory entres

ls -l |grep -v ^d
gives on the non-directory entries

ls -l |grep ^d && ls -l |grep -v ^d
gives both together. (It won't pipe well through less though.)

Although you get multiple page sets with
ls -l |grep ^d |less && ls -l |grep -v ^d |less
(first page through the directories, then the non-directories)

Now ~I'm~ intrigued enough to make a solution I like better.
Back to top
View user's profile Send private message
ClippyHater
Apprentice
Apprentice


Joined: 06 Nov 2002
Posts: 247
Location: Wisconsin

PostPosted: Tue Mar 18, 2003 12:30 am    Post subject: Reply with quote

Wow jfb3, thanks a ton :)
Back to top
View user's profile Send private message
TheEternalVortex
Apprentice
Apprentice


Joined: 15 Oct 2002
Posts: 207
Location: San Jose, CA

PostPosted: Tue Mar 18, 2003 1:57 am    Post subject: Reply with quote

You could make a Perl script:

Code:

#!/usr/bin/perl
use strict;

my $ls = "ls -l"; # set colors, etc. here
my $out = `$ls | grep ^d`;
$out .= `$ls | grep -v ^d`;
print $out;


You can then call it with less:
ls.pl | less
_________________
-- Andy
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot 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