Is there a way to print the ASCII charachter '├── ' and '└──' using a bash or perl script? I want it be exactly like the output of 'tree'.
[root@localhost www]# tree -L 1
.
├── cgi-bin
├── error
├── html
└── icons
When you type Alt + numbers in Windows, you are actually typing Alt + character's ASCII code. To achieve the same in Ubuntu, you must type Ctrl + Shift + U , and then type character in Unicode hexadecimal value.
Upon completion of listing all files and directories found, tree returns the total number of files and directories listed. There are options to change the characters used in the output, and to use color output. The command is available in MS-DOS versions 3.2 and later and IBM PC DOS releases 2 and later.
A backslash followed by any other character maps to that character. Character range. For non-octal range endpoints represents the range of characters between the range endpoints, inclusive and in ascending order, as defined by the collation sequence.
They look to be a part of the extended ascii codes. You can see them here http://www.asciitable.com/
Also available at the Unicode table here: http://unicode-table.com/en/sections/box-drawing/
I believe 192, 195 and 196 are the ones you are after. In Unicode 2501, 2514 and 2523.
EDIT
Found a related stack question here, which recommends printing in Unicode.
What you want is to be able to print unicode, and the answer is in
perldoc perluniintro
. You can use\x{nnnn}
where n is the hex identifier, or you can do\N{...}
with the name:
perl -E 'say "\x{2514}"; use charnames; say "\N{BOX DRAWINGS LIGHT UP AND RIGHT}"'
echo -e "\0342\0224\0224\0342\0224\0200\0342\0224\0200 \033[01"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With