|
|
You can use cat with redirection to append a file to another file. You do this by using the append redirection symbol, ``>>''. To append one file to the end of another, type cat, the file you want to append, then >>, then the file you want to append to, and press <Enter>.
For example, to append a file called report2 to the
end of report1, type:
cat report2 >> report1
You can use the append symbol ``>>'' with any command that writes
output.
For example, you could append a directory listing to a file called
log with:
ls >> log
Try working through the following cat tutorial:
Type cat > report1 and press <Enter>. Type report 1 and press <Enter>. Then, type Keeping a cat is a serious responsibility and press <Enter>. Now, press <Ctrl>D.
Create report2 by typing cat > report2 and pressing <Enter>. Type report 2 and press <Enter>. Then, type Cats need a balanced diet and press <Enter>. Now, press <Ctrl>D.
Create report3 by typing cat > report3 and pressing <Enter>. Type report 3 and press <Enter>. Then, type Responsible cat owners will neuter or spay their pets and press <Enter>. Now, press <Ctrl>D.
$cat > report1 report 1 Keeping a cat is a serious responsibility
<Ctrl>D
$cat > report2 report 2 Cats need a balanced diet
<Ctrl>D
$cat > report3 report 3 Responsible cat owners will neuter or spay their pets
<Ctrl>D
$cat report1 report2 report3 > allreps cat allreps
report 1 Keeping a cat is a serious responsibility report 2 Cats need a balanced diet report 3 Responsible cat owners will neuter or spay their pets $cat report3 report2 > repsagain
$cat report1 >> repsagain
$cat repsagain
report 3 Responsible cat owners will neuter or spay their pets report 2 Cats need a balanced diet report 1 Keeping a cat is a serious responsibility