On 30.08.2021 04:13, hongy...@gmail.com wrote:
The following command will print red text output on terminal:
$ echo -e '\e[31mRED TEXT\e[m'This is no portable shell syntax. My Kornshell, for example, wants
echo $'\e[31mRED TEXT\e[m'
or
printf "\e[31mRED TEXT\e[m"
RED TEXT
But why it uses such a strange syntax,The '\e' character is ESC and '[' introduces the CSI; You may find
more detailled answers for CSI (Control Sequence Introducer) here: https://en.wikipedia.org/wiki/ANSI_escape_code
and how to understand/remember it conveniently?Look it up in tables (e.g. on the page linked above).
Janis
Regards,
HY
The following command will print red text output on terminal:
$ echo -e '\e[31mRED TEXT\e[m'
RED TEXT
But why it uses such a strange syntax,
and how to understand/remember it conveniently?
Regards,
HY
On Monday, August 30, 2021 at 10:29:18 AM UTC+8, Janis Papanagnou wrote:
On 30.08.2021 04:13, hongy...@gmail.com wrote:
The following command will print red text output on terminal:This is no portable shell syntax. My Kornshell, for example, wants
$ echo -e '\e[31mRED TEXT\e[m'
echo $'\e[31mRED TEXT\e[m'
or
printf "\e[31mRED TEXT\e[m"
They are all work in bash too.
The following command will print red text output on terminal:
$ echo -e '\e[31mRED TEXT\e[m'
RED TEXT
But why it uses such a strange syntax, and how to understand/remember
it conveniently?
There are a lot of things that talk about the SGR options, particularly colors. Fewer will talk about the different things that you can do with fonts. -- Both of the sites I linked to will talk about fonts. It's a matter of what your terminal (emulator) supports. -- You'll find that there are few sites that talk about more of the fancier things that you
can do. }:-) Double height and / or double width text is ... something
to behold. As are Sixel and ReGIS graphics in a text terminal. (No Unicode pseudo graphics via Braille characters here.)
The following command will print red text output on terminal:
$ echo -e '\e[31mRED TEXT\e[m'
RED TEXT
But why it uses such a strange syntax, and how to understand/remember
it conveniently?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 237:53:12 |
Calls: | 6,624 |
Files: | 12,172 |
Messages: | 5,319,878 |