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; what it is most useful for is 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 to. The vi program has two modes: Edit and Command. In the Edit mode, you can enter and edit text. In the Command mode, you issue commands to the program.
NOTE To save long manual pages for a command, use the man command on that command and use the spacebar to reveal the entire text of the manual pages. Select the manual text you want to save in a file and choose 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 you have GUI text editors 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 will open 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 it is unlikely that you will be able to figure them out without help. Compressing, Uncompressing, and Extracting FilesUnix has some "built-in" programs to enable you to work with compressed files.
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. |