LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   directories first in ls display? (https://www.linuxquestions.org/questions/linux-newbie-8/directories-first-in-ls-display-308902/)

gjhicks 04-02-2005 06:09 AM

directories first in ls display?
 
Hi,

I am having trouble fuguring out how to issue the 'ls' command so that the directories are listed first.

Also, I would like to use the 'ls' command to sort by file extension.

Can anyone help with these (probably simple!) pieces of syntax?

Regards,

Geoff.

gootz 04-02-2005 09:53 AM

Hi,

I think
$> ls -X
is what you're looking for. (Don't forget to capitalize the X.)

Götz

gjhicks 04-02-2005 01:58 PM

Hi,

Thanks for the help.

Yes, the command 'ls -lX' displays the files in order by their extension.

Any idea how to get the directories to list first?

Regards,

Geoff.

Genesee 04-02-2005 03:40 PM

:scratch: not sure if there's a flag for ls for that

you could always capitalize the dir's and keep files lowercase.....

mnia 07-14-2009 06:20 PM

ls --group-directories-first
 
Hi hi. Is this what you're looking for?

By the way, if my directories *are* capiltalised, then how do i use the ls command to sort alphabetically with capitals first, before lowercase? Default ls sorting seems to ignore capitals. (Just curious).

Tinkster 07-14-2009 06:30 PM

Quote:

Originally Posted by mnia (Post 3607789)
Hi hi. Is this what you're looking for?

I guess it would have been if ls 4 years ago had had that switch.

Quote:

Originally Posted by mnia (Post 3607789)
By the way, if my directories *are* capiltalised, then how do i use the ls command to sort alphabetically with capitals first, before lowercase? Default ls sorting seems to ignore capitals. (Just curious).

By setting your collate order to C.
Code:

export LC_COLLATE=C

Cheers,
Tink


P.S.: For future reference: if you have questions, please
don't dig up corpses of long gone threads to tack them on
to the end of those.



Cheers,
Tink

BeacoN 07-14-2009 10:11 PM

directory listing
 
a simple listing of all directories immediately under pwd...

find ./ -maxdepth 1 -type d

more information about those directories (I have this command aliased in .bash_profile)...

ls -l | grep ^d

:-)

BeacoN 07-14-2009 10:13 PM

*cough*
 
wow Tink you're right....this thread is a bit dusty....

mnia 07-14-2009 11:34 PM

apologies
 
sorry, first post in a forum --- i'm (obviously) not versed on the etiquette. found it on a google search when looking for the same problem... thought i might be helpful to the question poser by posting what i'd found. but, ahem, apparently not.

thanks for the replies anyhoo. next time (if i get up the courage to post something again) i will look at the date.

Tinkster 07-15-2009 12:51 PM

Quote:

Originally Posted by mnia (Post 3607975)
sorry, first post in a forum --- i'm (obviously) not versed on the etiquette.

No worries - that's what the corrective feed-back is there for ;}

Quote:

Originally Posted by mnia (Post 3607975)
found it on a google search when looking for the same problem... thought i might be helpful to the question poser by posting what i'd found. but, ahem, apparently not.

Well, we'll find out should the original poster re-appear. :}

Quote:

Originally Posted by mnia (Post 3607975)
thanks for the replies anyhoo. next time (if i get up the courage to post something again) i will look at the date.

Oh please ... don't let me discourage you!


Cheers,
Tink


All times are GMT -5. The time now is 02:05 AM.