# Tree command does not print properly

**URL:** <https://community.unix.com/t/tree-command-does-not-print-properly/351828>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [April 9, 2015, 2:02am UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828 "2015-04-09T02:02:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![stew](https://community.unix.com/letter_avatar/stew/32/6_22734026db12803ebb3e059622ac3534.png) [@stew](https://community.unix.com/u/stew)\
**Post date:** [April 9, 2015, 2:02am UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828/1 "2015-04-09T02:02:20Z")

</div>

Hi,

when I run tree command in linux box getting below image, not the line

```nohighlight
 
test
��� lost+found
��� test1
�� � ��� aaa.txt
�� � ��� bbb.txt
��� test2
3 directories, 2 files

```

installed tree-1.5.3-2.el6.x86\_64 package

---

<div class="post-metadata">

**Author:** ![radoulov](https://community.unix.com/user_avatar/community.unix.com/radoulov/32/489_2.png) [@radoulov](https://community.unix.com/u/radoulov)\
**Post date:** [April 9, 2015, 2:45am UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828/2 "2015-04-09T02:45:52Z")

</div>

Try:

```nohighlight
LC_ALL=C tree

```

---

<div class="post-metadata">

**Author:** ![stew](https://community.unix.com/letter_avatar/stew/32/6_22734026db12803ebb3e059622ac3534.png) [@stew](https://community.unix.com/u/stew)\
**Post date:** [April 9, 2015, 5:14am UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828/3 "2015-04-09T05:14:55Z")

</div>

Thanks, it worked.

---

<div class="post-metadata">

**Author:** ![stew](https://community.unix.com/letter_avatar/stew/32/6_22734026db12803ebb3e059622ac3534.png) [@stew](https://community.unix.com/u/stew)\
**Post date:** [May 25, 2015, 8:26am UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828/4 "2015-05-25T08:26:44Z")

</div>

I know this very old, but I have a question. still when I run tree command I am getting same junk what I posted in my first post.

But when I run below command, tree structure getting

```nohighlight
 
LC_ALL=C tree

```

what is permanent solution to print tree structure with "tree" command.

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_22734026db12803ebb3e059622ac3534.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [May 25, 2015, 11:31am UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828/5 "2015-05-25T11:31:09Z")

</div>

Maybe your character set is set to UTF-8 when you don't actually have a UTF-8 terminal. LC\_ALL=C prevents it from trying to use fancy unicode line-printing characters.

---

<div class="post-metadata">

**Author:** ![fpmurphy](https://community.unix.com/user_avatar/community.unix.com/fpmurphy/32/110_2.png) [@fpmurphy](https://community.unix.com/u/fpmurphy)\
**Post date:** [May 25, 2015, 11:32am UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828/6 "2015-05-25T11:32:21Z")

</div>

What is the output of your locale command?

---

<div class="post-metadata">

**Author:** ![bakunin](https://community.unix.com/letter_avatar/bakunin/32/6_22734026db12803ebb3e059622ac3534.png) [@bakunin](https://community.unix.com/u/bakunin)\
**Post date:** [May 25, 2015, 3:20pm UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828/7 "2015-05-25T15:20:29Z")

</div>

> [@stew](#):
>
> But when I run below command, tree structure getting
> 
> ```plaintext
>  
> LC_ALL=C tree
> 
> ```
> 
> what is permanent solution to print tree structure with "tree" command.

The set of language-specific characters in your environment is (maybe erronously) set so that the line-drawing characters are replaced by some other characters (which you called "junk"). Which set of characters is taking these places (german umlauts, french accents, ....) is controlled by the "LC\_ALL" variable. To set this variable to "C" means to use a set of characters without any diacriticals at all, which is enough for english language but probably no other.

When you enter a certain setting for a variable and then a command it means that the value for this variable is in effect only for this one command. This means:

```plaintext
# LC_ALL=C tree
# tree

```

The first of the two commands will have set LC\_ALL to "C" and therefore work, the second one will produce junk again because "LC\_ALL" is set to something else.

Solution: set the variable somewhere where it has a lasting effect. The best place is your shells startup file: "~/.kshrc" if you use `ksh` (Korn shell), "~/.bashrc" if you use `bash` (Bourne Again Shell).

Put in the respective file the following line:

```plaintext
LC_ALL=C ; export LC_ALL

```

and start a new shell.

I hope this helps.

bakunin

---

<div class="post-metadata">

**Author:** ![stew](https://community.unix.com/letter_avatar/stew/32/6_22734026db12803ebb3e059622ac3534.png) [@stew](https://community.unix.com/u/stew)\
**Post date:** [May 27, 2015, 4:34am UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828/8 "2015-05-27T04:34:04Z")

</div>

I appended

```nohighlight
LC_ALL=C ; export LC_ALL

```

in .bash\_profile, but the entire locale variable has changed.

```nohighlight
 
LC_CTYPE=C
LC_NUMERIC=C
LC_TIME=C
LC_COLLATE=C
LC_MONETARY=C
LC_MESSAGES=C
LC_PAPER=C
LC_NAME=C
LC_ADDRESS=C
LC_TELEPHONE=C
LC_MEASUREMENT=C
LC_IDENTIFICATION=C
LC_ALL=C

```

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_22734026db12803ebb3e059622ac3534.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [May 27, 2015, 11:26am UTC](https://community.unix.com/t/tree-command-does-not-print-properly/351828/9 "2015-05-27T11:26:53Z")

</div>

It does that. It's a special variable.

```nohighlight
$ man bash
...
       LC_ALL This variable overrides the value of LANG and any other LC_
              variable specifying a locale category.
...

```

The alternative to altering the locale would be to fix your terminal. What are you using?
