You can use the cat command to create a file quickly by typing cat > filename. cat creates a file named filename, and puts the text you type into the file, until you tell it you have finished by pressing <Ctrl>D. (The name cat is short for concatenate, or join together; this is another thing the cat command can do.)
$Using cat to write a file is like writing a mail message: you can backspace to correct mistakes within a line, but you cannot backspace past the beginning of the line you are on. The vi editor, discussed later in this chapter, lets you correct mistakes anywhere in a file.
cat > todo write staff report review budget figures return doug's call<Ctrl>
Try writing a file with cat:
cd; pwd/u/susannah $
cat > mytodo write status report fill out timesheet buy cat food<Ctrl>
l mytodo-rw-rw---- 1 susannah techpubs 52 Jun 24 12:12 mytodo
What if I see a message like:
mytodo: Permission denied or
mytodo: cannot create?
When you see a
Permission denied or
cannot create message,
you do not have permission to write in the
directory where cat is trying to create a file.
(File and directory permissions are covered in
``Protecting files and directories''.)
Try changing to your home directory by typing
cd and pressing <Enter>, then try opening up your new file there.