What can you do with the "cat" command?

What can you do with the "cat" command?

What does "cat temp1.c" do? What other things can you accomplish with the "cat" command?

    Requires Free Membership to View

    When you register, my team of editors will also send you resources covering Linux administration and management; integration and interoperability between Linux, Windows and Unix; securing Linux and mixed-platform environments; and migrating to Linux.

    Margie Semilof, Editorial Director

    By submitting your registration information to SearchEnterpriseLinux.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchEnterpriseLinux.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

The cat command allows you to view, modify or combine a file, depending upon what (if any) flags you are using. In this case, you are just viewing the contents of the specified file to the screen (standard output). If the file you are attempting to view is not in text format, you will get a bunch of gibberish. For certain types of files, especially core files, the strings command will be of more use to you.

Some other options for the cat command are as follows:

  • -n: Add line numbers to output.
  • -b: Add line numbers to output but do not number blank lines.
  • -v: Display nonprinting and control characters.
  • -e: Print a dollar sign ($) at the end of each line of output. Must be used with the -v option.
  • -t: Print a ^I for each tab and ^L for each form feed. Must be used with the -v option.
  • -s: On most systems this option causes cat not to print error messages about non-existent files. On some older systems -s causes cat to skip blank lines in the output.
  • -u: Do not buffer output. By default, output is buffered in blocks or screen lines.

Editor's note: For more information on the "cat" command, read this expert response from Nigel McFarlane.

This was first published in August 2004