I'm trying to list the contents of a directory recursively and in color using the tree -C command. However, my shell reports an error and it displays an info-entry for sed instead. The tree command by itself works fine but it seems that a number of the options (e.g., tree -a) are not available to me.

I've tried installing a new version using sudo apt-get install tree but no luck. I'm experiencing this behavior in both bash and zsh (LXDE/Ubuntu 14.04).

Any suggestions that would allow me to use tree with the full set of options (listed here: http://linux.die.net/man/1/tree)?

~ tree -C                                                                 ⏎
sed: invalid option -- 'C'
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
                 follow symlinks when processing in place
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if SUFFIX supplied)
  -l N, --line-length=N
                 specify the desired line-wrap length for the `l' command
                 disable all GNU extensions.
  -r, --regexp-extended
                 use extended regular expressions in the script.
  -s, --separate
                 consider files as separate rather than as a single continuous
                 long stream.
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
  -z, --null-data
                 separate lines by NUL characters
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.

I don't have the reputation to comment, so I'll put this here.

It almost looks like the tree command is aliased to sed on your machine. When I run tree -C on my machine, I get the expected behavior. When I run sed -C on my computer, I get the exact same output that you get when you run tree -C.

Is there any entry in your ~/.bashrc file that defines an alias like that?

  • bingo. i'd added some predefined aliases a while ago that i'd forgotten about, including one for tree. at the time, i didn't know about the tree package for Ubunutu... – iceman Nov 1 '14 at 19:09

You can try the tree command as:

tree /boot/
tree -d /boot/
tree -C /boot/
  • Without further explanation this is more of a comment than an answer. – agtoever Nov 1 '14 at 19:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.