next up previous contents
Next: File conventions, UNIX vs. Up: Files and the File Previous: Creating files: Using the   Contents

Appending to a file (cat >>)

If you wish to add to a file instead of wiping its contents out, as > does, then redirect the output using the symbol >>. The append redirecting output symbol >> works similarly to the append command in VMS. To add the contents of one file to another use the command cat and then replace the > sign with the >> sign. E.g.:

malama% cat night >> day Unlike the previous example the contents of the file ``day'' will not be obliterated; instead the contents of the file ``night'' will be added at the end of the file ``day''.

You can use either > or >> to redirect the output of a command. If, for example, you wished to have output from a program go to a file instead of the screen, you would use: malama% myprog > outfile The file ``outfile'' will contain the output from your program. Now, supposing you made some change to your program and wished to have the output from a second run added to the first. Instead of using > , which would wipe out the first output, you would use >> .

malama% myprog >> outfile ``outfile'' will contain two sets of output from the program myprog.


next up previous contents
Next: File conventions, UNIX vs. Up: Files and the File Previous: Creating files: Using the   Contents
h.stilmack@jach.hawaii.edu