View previous topic :: View next topic |
Author |
Message |
ClippyHater Apprentice
Joined: 06 Nov 2002 Posts: 247 Location: Wisconsin
|
Posted: Sun Mar 16, 2003 2:30 am Post subject: ls questions from a noob... |
|
|
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 |
|
|
evidence Tux's lil' helper
Joined: 04 Nov 2002 Posts: 85
|
Posted: Sun Mar 16, 2003 3:57 am Post subject: |
|
|
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 |
|
|
ClippyHater Apprentice
Joined: 06 Nov 2002 Posts: 247 Location: Wisconsin
|
Posted: Sun Mar 16, 2003 12:16 pm Post subject: |
|
|
Thanks! |
|
Back to top |
|
|
ClippyHater Apprentice
Joined: 06 Nov 2002 Posts: 247 Location: Wisconsin
|
Posted: Sun Mar 16, 2003 1:58 pm Post subject: |
|
|
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 |
|
|
jfb3 Apprentice
Joined: 01 Feb 2003 Posts: 242
|
Posted: Mon Mar 17, 2003 9:28 am Post subject: Here's a first draft |
|
|
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 |
|
|
ClippyHater Apprentice
Joined: 06 Nov 2002 Posts: 247 Location: Wisconsin
|
Posted: Tue Mar 18, 2003 12:30 am Post subject: |
|
|
Wow jfb3, thanks a ton |
|
Back to top |
|
|
TheEternalVortex Apprentice
Joined: 15 Oct 2002 Posts: 207 Location: San Jose, CA
|
Posted: Tue Mar 18, 2003 1:57 am Post subject: |
|
|
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 |
|
|
|