One of the most important skills in any computer system is knowing how to work with files. A file is a collection of characters that the operating system treats as a unit. Files can store any information you want to save. For example, files can contain text for letters and email messages, code for programs, or data for calculations. After you create a file, you can add material to it, delete material from it, or remove it from the system.
/ \ " ` ' * | ! ? ~ $ < > &
File names may be between 1 and 255 characters long, but you will find that short, descriptive names are easiest to use. File names should not contain spaces. Instead of spaces, use underscores or periods to separate names made of multiple words, as follows:
mail.Jan annual_report unix_tips
Also, Unix distinguishes between uppercase and lowercase letters. For example, Unix would treat these as three different files:
project1 Project1 PROJECT1
, vi, and others. If you are
a beginning Unix user, you might prefer Pico to vi for the
following reasons:
To create a new file using the Pico text editor, enter:
pico file
Note: the p in the pico command is lowercase.
This starts the Pico text editor and opens a blank file. Pico assigns to that file the name you specify. Use your keyboard to add text to the file.
To save a file and exit the Pico text editor:
To re-open and edit a file with the Pico text editor, enter:
pico file
Where file is the name of the file you want to edit.
|
To create a file named sport.quote,
enter:
pico sport.quote This starts the Pico text editor with the file sport.quote. Add to this file the following lines of text:
It ain't over till it's
over. When you finish typing, save and exit sport.quote using the three steps that precede this example. To re-open and edit sport.quote, enter: pico sport.quote |
ls
Your list might resemble the following:
mail murphy.law phone.dir sport.quote
For more on the ls command, see List the Contents of a Directory
cp file1 file2
This creates a copy of file1 and names it file2.
To copy a file to a different directory, enter:
cp file directory
This creates a copy of the file you specify in directory the you specify.
For more information on directories, see Working With Directories.
mv file1 file2
This changes the name of file1 to file2.
more file
This starts the more program, which lets you view the file you specify one screen at a time. Use <Spacebar> to scroll forward one screen, <Return> to scroll forward one line, and q to quit the more program. To search for a word in the file, type / followed by the word and then press <Return>.
rm file
This permanently removes the file you specify. A safe way to give the rm command is with the -i option. With the -i option, you are prompted before a file is permanently removed.
To require a prompt before a file is deleted, enter:
rm -i file
In response to the prompt, enter y to remove the file or n to keep the file.
A second method for printing from a Uniform Access computer to a desktop printer is with the ansiprint command. This command will only work for selected types of equipment and software. PCs and Macs should work if they run an up to date terminal session program such as Tera Term Pro, or Better Telnet.
To print a file to your desktop printer, enter:
ansiprint file