tags 9344 + notabug thanks 博高 wrote: > Hello: > I am a user of ubuntu 10.04.2.While I am trying to use 'cat' to > display a binary file.....Every letter on my display goes wrong.... > yours GB from China
The 'cat' program copies each file to standard output concatenating files. It is working properly. What you are seeing are the contents of the files to the terminal. Whether the terminal can display that binary data or not is not a bug in cat. Your data is almost certainly in a character encoding that is not understood by the terminal. You could reconfigure the terminal or recode the file into a different characer set. Since the purpose of 'cat' is to concatenate files it must not modify or filter the files in the process. What goes in should come out. The 'cat' program is typically used to assemble parts of files together. It is doing that correctly. To browse files you should use a file browser such as 'more', 'less', 'most', or other programs that act as terminal pagers. For binary files it may be more useful to use 'od -tx1', 'hexdump', 'xxd' or other program that converts binary data into text codes and then piping the output to a pager. It is historically traditional on Unix-like systems to use cat to write short text files to the terminal. However this is done with full knowledge that it only behaves as desired on short text files that do not contain terminal control sequences. If they do then the user running cat to write the file to the terminal must be prepared to accept the consequences and be able to reset the terminal if needed. Since this is not a bug in cat but instead a misuse of it I am going to close the bug report. Hope this helps, Bob
