Welcome to the VirtuQ Forums.
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Oct 2011
    Location
    Allahabad, India
    Posts
    245

    ls --color[=WHEN] command

    Hi,

    ls --color[=WHEN] command says that it control the color whether color is used to distinguished file types. WHEN may be `never', `always' or `auto'.

    Firstly,I am unable to understand it what does it want to say?

    Secondly, when I typed the command ls --color[=`always'] it will come like this
    >
    >
    >
    >

    and I am unable to exit out of this.

    Help Me

    Regards
    Anon10020

  2. #2
    VirtuQ™ Moderator
    Join Date
    Jul 2011
    Location
    Bangalore, India
    Posts
    1,044
    Blog Entries
    2
    Anon10020,

    Recall the slide on command conventions, anything in [] is optional. So, the correct commands to type are:

    ls --color=always
    ls --color=none
    ls --color=auto

    In our standard xterm color is always enabled and hence you will notice that color shows up. In cases where the terminal cannot support color, then you want to have ls --color=none so that your terminal does not show garbled up characters. Solaris, AIX and HP-UX typically will have default terminal emulators which cannot display color. It is only on Linux that the default terminal emulator can display color.

    ls --color=auto is interesting because it is useful for scripts. If there is no tty connected to the output then color will not be displayed. To understand this problem, do the following:

    ls --color > a

    vim a

    Note that in the opened file you will see all weird characters with [[03.. These are the color sequences for this particular terminal emulator. To exit from vim press <SHIFT>-<z>-<z> i.e. shift and 'z' pressed together and then again 'z' pressed after releasing it once. Now if you issue the following command:

    cat a

    The output will appear just fine that is because the terminal is able to infer the [[03.. sequences and convert them to color. Start an xterm as:

    xterm -cm

    and issue the command

    cat a

    in this terminal, you will notice that the colors are not there. That is because xterm -cm tells xterm to ignore ASCII color codes.

    Hope that clarifies it.

    To break from any command in UNIX, try <CTRL>-c.

    Cheers,

    Anup
    Last edited by anup; 18-10-2011 at 09:08 AM.

  3. #3
    Member
    Join Date
    Oct 2011
    Location
    Allahabad, India
    Posts
    245
    Thank You

    Regards
    Anon10020


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •