Live data from Hacker News

An Illustrated Guide to Useful Command Line Tools

wezm.net

41–50 of 108 posts

Re: An Illustrated Guide to Useful Command Line Tools

#41
post #39

Can someone explain the misuse of cat, which bat solves?

Catting a file will your terminal make interpret escape codes in the file. For instance: $ echo -e "\033]0;${USER} is an unfriendly person\007" > test-file.txt Then, many days later: $ cat test-file.txt will change your terminal title. With less, you _can_ interpret escape codes, but usually you don't, and I consider this the correct default.

That's a surprising and interesting bit if knowledge, thanks

Re: An Illustrated Guide to Useful Command Line Tools

#42
post #39

Can someone explain the misuse of cat, which bat solves?

Catting a file will your terminal make interpret escape codes in the file. For instance: $ echo -e "\033]0;${USER} is an unfriendly person\007" > test-file.txt Then, many days later: $ cat test-file.txt will change your terminal title. With less, you _can_ interpret escape codes, but usually you don't, and I consider this the correct default.

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

#45
post #39

Can someone explain the misuse of cat, which bat solves?

Catting a file will your terminal make interpret escape codes in the file. For instance: $ echo -e "\033]0;${USER} is an unfriendly person\007" > test-file.txt Then, many days later: $ cat test-file.txt will change your terminal title. With less, you _can_ interpret escape codes, but usually you don't, and I consider this the correct default.

in your example it is not cat who "interprets" the escapes, but echo

Re: An Illustrated Guide to Useful Command Line Tools

#49
As much as I do use a number of these tools, there's something to be said for being able to use any box you ssh or log into that has the default tools available on any *nix system. ls, cat, find, etc. I'm hypocritical a bit in that I do use rg, and fd, but I just can't bring myself to deviate too far from the 'default'.

Re: An Illustrated Guide to Useful Command Line Tools

#50
post #41
post #39

Earlier quoted context omitted.

Catting a file will your terminal make interpret escape codes in the file. For instance: $ echo -e "\033]0;${USER} is an unfriendly person\007" > test-file.txt Then, many days later: $ cat test-file.txt will change your terminal title. With less, you _can_ interpret escape codes, but usually you don't, and I consider this the correct default.

That's a surprising and interesting bit if knowledge, thanks

'less -R' is useful because it will honour colour control codes while escaping other ones (like title changes, terminal bell, etc)
Post reply on HN