You learned earlier that several Unix applications are included with Mac OS X. Although you aren't likely to use these instead of your Mac OS X applications for your everyday work, sometimes these applications can be quite useful. For example, you might want to use the vi text editor to create Shell scripts. A couple of examples will show you how such applications work. Editing Text with viThe Unix application vi is a basic text editor. You can use it to create and edit text files, but it is most useful for creating Shell scripts. You are unlikely to use it to create text documents, but you can use it to create plain-text documents if you would like. The vi program has two modes: Edit and Command. In Edit mode, you can enter and edit text. In Command mode, you issue commands to the program. Do the following:
TIP To save long manual pages for a command, use the man command on that command and press the spacebar to reveal the entire text of the manual pages. Select the manual text you want to save in a file and select File, Save Selected Text As. Name the text file and save it. You can then refer to that file when you need help with that command. Because GUI text editors are available, you might not want to use Unix text editors such as vi, but for short, plain-text documents, such as a Shell script, these editors can be useful. To edit an existing file with vi, type vi filename, where filename is the name of the file you want to edit, and press Return. The file opens and you can begin editing it. If you intend to use vi, make sure that you read its manual pages in detail; vi has many commands available, but they are hard to figure out without help. Compressing, Uncompressing, and Extracting FilesUnix has some built-in programs to enable you to work with compressed files, including the following:
Many Unix files are archived in the tar (tape archive) format before they are compressed. After you compress such files, you will see a file that has the .tar extension. You can extract a tar file using the command tar xvf filename, where filename is the name of the tar file. NOTE Tar also has various options; check its manual pages for help. |