Ask your own question, for FREE!
Computer Science 28 Online
OpenStudy (anonymous):

why does `cat' ing a binary file mess up your shell?

OpenStudy (shadowfiend):

Shells are fundamentally based on characters. Everything you type translates to a string of characters. So backspace for a shell translates to a set of bytes sent that are interpreted before they hit the screen. When you cat a binary file, the shell sees all the characters from the file, and will probably run across a bunch of control codes that change a variety of things about the shell's mode. If you get unlucky on the contents of the file, you can end up with a totally hosed terminal.

OpenStudy (rsmith6559):

A binary file can have any value of a byte. Check all the values against a table of Extended ASCII values, and you can see some very interesting possibilities. BTW, I'm not sure the shell is messed up, but stdout sure is.

OpenStudy (shadowfiend):

Or more specifically the interpretation of stdout :)

OpenStudy (anonymous):

can you do harm to pc just using cat on binary file?

OpenStudy (rsmith6559):

I seriously doubt that anything permanent can be done. However, it is a good habit (especially when I remember to do it) to run the file command on any file that you're thinking of looking at.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!