Login Register Sign up for the GRM e-newsletter

Login to post Forums » Off-topic discussion » Computer peeps: basic dumb Linux question
  • Jay

    June 4, 2009 4:40 a.m. Jay Dork

    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

    June 4, 2009 7:04 a.m. Grtechguy UltraDork

    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

    June 4, 2009 9:43 a.m. EricM HalfDork

    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

    June 4, 2009 11:24 a.m. jeffmx5 New Reader

    Too long for a post...

    Google Books - Linux Hacks

  • GameboyRMH

    June 4, 2009 1:42 p.m. GameboyRMH SuperDork

    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

    June 5, 2009 4:11 a.m. Jay Dork

    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.