LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-02-2005, 07:09 AM   #1
gjhicks
Member
 
Registered: Jun 2004
Location: Melbourne, Australia
Posts: 47

Rep: Reputation: 15
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.
 
Old 04-02-2005, 10:53 AM   #2
gootz
LQ Newbie
 
Registered: Jan 2005
Location: Pirna, Germany
Distribution: Knoppix 3.6
Posts: 7

Rep: Reputation: 0
Hi,

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

Götz
 
Old 04-02-2005, 02:58 PM   #3
gjhicks
Member
 
Registered: Jun 2004
Location: Melbourne, Australia
Posts: 47

Original Poster
Rep: Reputation: 15
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.
 
Old 04-02-2005, 04:40 PM   #4
Genesee
Member
 
Registered: Dec 2002
Distribution: Slackware
Posts: 927

Rep: Reputation: 30
not sure if there's a flag for ls for that

you could always capitalize the dir's and keep files lowercase.....
 
Old 07-14-2009, 07:20 PM   #5
mnia
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 1
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).
 
1 members found this post helpful.
Old 07-14-2009, 07:30 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by mnia View Post
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 View Post
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
 
Old 07-14-2009, 11:11 PM   #7
BeacoN
Member
 
Registered: Nov 2008
Distribution: Linux Mint
Posts: 56

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

:-)
 
Old 07-14-2009, 11:13 PM   #8
BeacoN
Member
 
Registered: Nov 2008
Distribution: Linux Mint
Posts: 56

Rep: Reputation: 17
*cough*

wow Tink you're right....this thread is a bit dusty....
 
Old 07-15-2009, 12:34 AM   #9
mnia
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 1
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.
 
Old 07-15-2009, 01:51 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by mnia View Post
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 View Post
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 View Post
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
 
  


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
putty display loops on listing directories with many files, through expect script vineet.k Linux - General 5 03-13-2007 10:44 AM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 01:23 PM
10.0 beta 4 tiny niggle -- SAMBA shares don't display all the directories 1kyle SUSE / openSUSE 1 09-10-2005 02:12 PM
I want ls to not display contents of directories GameboyHippo Linux - Newbie 2 01-26-2004 04:47 AM
Display wide listing of files and directories only? northfield Linux - General 3 08-21-2002 07:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:27 AM.

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