| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
cat - Concatenate Files And Print To The Standard Output The cat command has three important uses, it can be used to display short files to the screen, append files together and output them to a third file, or it can be used to input text from the keyboard to a file. To display a short file to the screen use: cat file_name This will copy the file, file_name, to the standard output which is the screen. The file command which will discussed later will identify non-ASCII files before they are viewed. To enter small amounts of data into a file the cat command to be used in the following form: cat > file This will cause whatever is entered on the keyboard to be displayed on the screen and simultaneously written to the file and will continue until the control key and the D key are pressed (^D) to send an end-of -file and terminate the process. This is an easy way to quickly enter small amounts of data into a file, however it is not possible to edit this data using cat, editing can be done with the vi editor, which will be discussed later in this section. When one needs to create a file and enter a small amount of data, this command can be more convenient than starting an editor to enter the data. The third form of the command is: cat file_1 file_2 > file_3 This will initially wipe out any contents of file_3 if it exists or create it if it does not and copy the contents of file_1 to file_3 and then append the contents of file_2 to file_3. The net result after this command executes is that file_3 will contain the contents of file_1 followed by the contents of file_2. The form: cat file_1 file_2 >> file_3 will append the contents of file_1 to the end of file_3 then append the contents of file_2 to the end of the new file_3. Now file_3 will contain its original contents, followed by the contents of file_1 then followed by the contents of file_2. It is important to remember the distinction between these two commands. If file three has contents, the first form will initially delete those contents before the command executes. Care must be taken to avoid inadvertently destroying the contents of an existing file.
Home - Table Of Contents - Contact Us CertiGuide to A+ (A+ 4 Real) (http://www.CertiGuide.com/apfr/) on CertiGuide.com Version 1.0 - Version Date: March 29, 2005 Adapted with permission from a work created by Tcat Houser et al. CertiGuide.com Version © Copyright 2005 Charles M. Kozierok. All Rights Reserved. Not responsible for any loss resulting from the use of this site. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||