Jay
Jay Dork
6/4/09 4:40 a.m.

Hopefully someone can answer this for me... So when I show a directory in Linux using "ls -l", it nicely colour codes everything for easy reading. However, when I use "ls -l | more" the "more" program strips away all the colours and makes me look at pages of featureless grey filenames. Is there a way to make "more" carry over the colours from the ls listing?

Also can I make ls show only directories? Or at least sort them to the top of the list like in DOS?

I'm using Suse 10.3 if it makes any difference.

Grtechguy
Grtechguy SuperDork
6/4/09 7:04 a.m.

crap... don't have a linux box by me right now, but I believe "ls dir" or "ls /" will give you what you want

EricM
EricM HalfDork
6/4/09 9:43 a.m.

why would "ls /" give him what he wants? That will just list the contents of the root directory...

I run all my commands through a terminal emulator so I only get black and white. Try using ls -l | less and see if that works, though I have no way of testing for colors. Do you need the colors? ls -l is the long listing and has the mode of each file listed. the colors help when you just do an ls without the -l and the color helps you wiht the mode.

anyway, that probably didn't help you.

jeffmx5
jeffmx5 New Reader
6/4/09 11:24 a.m.

Too long for a post...

Google Books - Linux Hacks

GameboyRMH
GameboyRMH SuperDork
6/4/09 1:42 p.m.

the --dirsfirst or --group-directories-first switch takes care of the directories...

-C is supposed to force coloring...

try:

ls -Clph --group-directories-first

http://www.computerhope.com/unix/uls.htm

Also see ls --help

BTW I don't know why you need the coloring, but I'd make things easier by piping the output to gedit instead of more.

Jay
Jay Dork
6/5/09 4:11 a.m.

That worked, Jeff! Looks like a good reference book too.

Gameboy, I don't seem to have --dirsfirst in this distro but --group-directories-first did it. Awesome. I need the colours because trying to find one file in pages of featureless grey text locks my brain instantly into "don't read this, it's boring" mode and I can never see what I'm looking for. Also I like 'more', it's simple and the output stays on screen after you quit so you can enter commands.

Thanks guys!

You'll need to log in to post.

Our Preferred Partners
y0ERDC7sBFuTrrprcIUgDE4sjQeZFDWATYVAhz5qPeagC3wpBJcyhfdYJV4qj2uJ