******* UNIX TUTORIAL - by Peter Conrad Cumminsky ******* ****** Lesson 4: File Management ****** ---------------------------------------------------------------------- ***** What is a file in UNIX? ***** A file is a collection of characters that is stored together, i.e. the words in a letter or paper, a computer program, or a listing of data. A directory (folder) is just a file that contains a list of files. ***** How to Name a File. ***** The filename must be all one word, no spaces allowed, about 14 characters or less. Don't begin a filename with a character that is not a letter or number. Never use the characters !, ", *, >, <, |,$,@, or ? as these have special meanings to the Shell. ***** How Do I Create a File? ***** %vi filename[Enter] ***** How Can I Add Text to this File? ***** (in Command Mode and Append Mode) a ***** How Do I get out of Append Mode? ***** [Esc] ***** How Do I Return to the Shell Prompt? ***** :ZZ ---------------------------------------------------------------------- ****** File Management with Shell Commands ****** ***** How Do I Copy a File? ***** %cp filename1 filename2 [Enter] ***** How Do I Remove a File? ***** %rm filename [Enter] ***** How Do I Change a Filename? ***** %mv old_filename new_filename [Enter] ***** How Do I View the Contents of a File? ***** %view filename (Lets you look at a file without changing it.) %cat filename (Scroll through the contents of a file.) [Ctrl]-[S] (Stops scrolling) [Spacebar] (Continues scrolling) %page filename [Enter] (Display the contents of a file one page at a time.) [Spacebar] (Views next screenful of text) [Delete] (Exits to Shell Prompt) %head filename [Enter] (Display the first ten lines of a file.) %tail filename [Enter] (Display the last ten lines of a file.) ***** How Do I Analyze the Contents of a File? ***** %grep word_to_find filename1 filename2 [Enter] (Find and list lines with word_to_find in filename1, etc.) %spell file_name > unknownwords [Enter] (Redirect the unknown words (by spell) in a file to the new file unknownwords.) %diction file_name > fuzzydiction [Enter] (Redirect the output of the diction command to the new file fuzzydiction.) %suggest word_or_phrase [Enter] (Suggests replacement diction for word or phrase.) ----------------------------------------------------------------------