I have been researching into the usage of the cat command on a deeper level (long story) and I was wanting to clarify understanding.
When we cat a binary, let's say the cat binary itself: cat /usr/bin/cat
we see that the terminal will slightly mess up as cat
interprets these as escape sequences, this seems down to how cat
interprets the bytes, but upon research, I did not find exactly how cat
achieves this.
A further example would be a simple bash script, in which we can do cat bash_script.sh | bash
and pipe it into bash to execute it as a bash script, this is the same for python etc.
So to summarise, I am wondering how cat
interprets the bytes as it reads them, and then how they are printed to the screen.
Any help is welcome, thanks in advance :)
question from:
https://stackoverflow.com/questions/66049010/how-does-cat-interpret-a-file-when-it-initially-reads-it 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…