$title = "Creating files"; $area = "Unix Support"; $metadata = "unix, commands, file, create, cat, echo"; $pfloc = ""; require '/usr/local/wwwdocs/ucs/fragments/header.phtml'; require '/usr/local/wwwdocs/ucs/fragments/header-bc.phtml'; ?>
Unix files are created as soon as their name is used in a command. Where a new file is only to contain a few lines of text, it is convenient to create it using the cat or echo commands.
Type the command
cat > name_of_file
Now type in your text. Press the <Return> key to start a new line.
When you have finished typing in your text, enter Ctrl-d (Press and hold down the Ctrl key and type a "d"). This stops the cat command and returns you to the system prompt.
Warning: do not use the name of a file that already exists. If you do, it will be overwritten by the new copy. To avoid this, set the shell variable noclobber.
cat > memo remember to make appointment at opticians get cost of scheduled flight to Athens Ctrl-d
This creates a file called memo in the current directory containing two lines of text.
To create a file, type the command echo and then continue to type the text that you want to appear in the file.
When you have finished typing in your text, type
> name_of_file
and press the <Return> key. This is useful for creating short files containing only one or two lines of text.
echo use an editor for large files > tips
This creates a file called tips in the current directory containing a single line of text.
require '/usr/local/wwwdocs/ucs/fragments/footer.phtml'; ?>