Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi.
Hope you could help me answer the following:
1. How does cat command works? Does the cat command read all the files first before copying to the output file or read the files per batch then copy to the output file?
2. Does cat command make use of other processes? Meaning if we issue the cat command in the Unix prompt, do other processes stops?
3. What's the maximum capacity of a single file (debug file) in Unix? Given the scenario that all debug files are open, does a single output file can accomodate the contents of all debug files?
4. Is the cat command dependent on the capacity of the files to be concatenated? Meaning, the bigger the file, the slower it would be for the cat command to finish the operation?
5. Given the maximum capacity of a single debug file, how long would it take for the cat command to finish the operation?
Also, make I ask any cautions that I should remember in using the cat command.
Hope to get feedback from you soon
Thank you.

Question four makes it sound like you believe that the 'cat' command concatenates files. That is not specifically true.
The cat command reads the file (or files) on it's command line and echos the file contents to standard out.
If you list multiple files on the command line and redirect the output to a single file, then you do, in effect, concatenate the files, but that is a result of how you used the command, not it's sole purpose.
I didn't write the 'cat' command nor have access to its source code, so these answers are based upon logic and my use of the 'cat' command.
Question 1 - it's highly unlikely that the cat command reads all of the files or even all of one file before it starts echoing to standard out. That would be highly inefficient and serve no purpose. Most likely it reads one line, outputs the line, then reads the next line. Reading entire files would mean that it would have to have a memory buffer large enough to hold the entire file. And there is no reason to have the entire file in memory at once.
Question 2.
Unix is a multi-user, multi-process system. Running a single process rarely effects other processes.Question 3.
I'm not a sys admin type, but I believe that the size of a file is limited only by the amount of disk space available in the file system that the file resides in. Many times I've seen run-away processes fill their log file until file system is full. At this point, things usually start crashing or locking up.I'm not sure I understand the second question. I think that you are asking if all of the log files can be copied to a single file. It depends on the size of all of your log files and the amount of hard drive space you have.
Question 4
Obviously, the larger the file the long the cat command will take. If I asked you to shovel two cubic yards of dirt and then asked you to shovel two cubic miles of dirt, would you do both in the same amount of time?Question 5
This would depend upon your system speed, disk speed, hard drive fragmentation, size of file, etc.The only caution that I can give, is don't drop your cat in the bathtub with a toaster. It'll run out of lives quick.
The cat command is pretty innocuous. It would be pretty hard to mess up stuff using the cat command. The only thing that I can think of is 'cat'ting a file and redirecting the output back to the same filename (cat myFile >myFile). That may cause problems.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |