Re:An Illustrated Guide to Useful Command Line Tools
by enriquto on Saturday October 26, 2019 @12:04PM
(#21364463)
in your example it is not cat who "interprets" the escapes, but echo
Re:An Illustrated Guide to Useful Command Line Tools
by eurg on Saturday October 26, 2019 @02:16PM
(#21365279)
Neither one interprets the sequence, but cat will print the file unfiltered to stdout, and stdout is processed by your terminal, and then the terminal will interpret it. less filters before printing to the terminal.
Re:An Illustrated Guide to Useful Command Line Tools
by enriquto on Saturday October 26, 2019 @04:50PM
(#21366094)
I meant that "echo -e" transforms the four characters "\033" into a single byte, for example. Thus, the sequence is "interpreted" by echo. Then, the cat program just copies the bytes without looking at them. If you want "cat" to escape these bytes so that they are not seen by the terminal you can use the "-v" option.
Re:An Illustrated Guide to Useful Command Line Tools
by kortilla on Saturday October 26, 2019 @10:54PM
(#21367627)
The sequence that translates to an escape code is interpreted by echo. The escape code is passed unfiltered by cat for the terminal to interpret.
Re:An Illustrated Guide to Useful Command Line Tools
by ISL on Saturday October 26, 2019 @12:00PM
(#21364430)
Tried it -- didn't work. Single-quoting didn't work either. Terminal is urxvt.
What is clear is that
$ cat test-file.txt
does not print the initially-echoed text, but it is escaped and up to nefarious tasks.
Re:An Illustrated Guide to Useful Command Line Tools
by eurg on Saturday October 26, 2019 @02:15PM
(#21365277)
The escape sequence is terminal specific. urxvt is likely different from xterm in this regard.
For instance:
Then, many days later: will change your terminal title.With less, you _can_ interpret escape codes, but usually you don't, and I consider this the correct default.