Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent unix tree from displaying back-slash before spaces

I use the command tree very often in command line (in Mac) and the tree structure of my current directory is listed as follows:

└── A\ File\ with\ Space.mp4

Is there an option to avoid displaying those back slashes?

like image 664
Jikku Jose Avatar asked Feb 08 '23 00:02

Jikku Jose


1 Answers

My tree command has a -N option to print non printable chars as is.

tree -N
.
├── a dirname with spaces
└── myscript.sh

Otherwise, you could use printf and xargs:

tree | xargs -L 1 -I xxxx printf "%s\n" xxxx
.
├── a dirname with spaces
└── myscript.sh

Special chars in names are going to break it or display surprising result: \n ' " * etc.

like image 164
Jay jargot Avatar answered Mar 16 '23 04:03

Jay jargot