Previous Next Contents

10. Useful Programs

10.1 Browsing Files: less

You'll use this file browser every day, so I'll give you a couple of tips to use it at best. First of all, ask your sysadm to configure less so as it can display not only plain text files, but also compressed files, archives, and so on.

The main advantage of less over TYPE is that you can browse files in both directions. It also accepts several commands that are issued pressing a key. The most useful are:

10.2 RCS in a Nutshell

The lack of version numbers in files can be easily overcome by using RCS (Revision Control System). This allows you to maintain several versions of the same file, and offers many more advantages. I'll only explain the very basics of this powerful version control system.

The most important commands are ci and co. The first (``check in'') is used to commit the changes you have done to your file, and create a new version. The second (``check out'') is used to obtain a working copy of your file from the RCS system, either to modify it or simply use it for browsing, printing, or whatever.

Let's see an example. First of all you create an initial revision of your file, using your favourite editor. Let's suppose that the file you'll have under RCS control is called project.tex. Follow these steps:

Using the latest version

Whenever you want to use, but not modify, the latest version of project.tex, you issue the command

$ co project.tex
RCS/project.tex,v  --> project.tex
revision 1.1

This extracts the latest version (read only) of your file. Now you can browse it, or compile it with tex, but you can't modify it.

Creating a new version

When you want to modify your file, you must obtain a ``lock'' on it. This means that RCS knows that you're about to make a newer version. In this case, you use the command

$ co project.tex
RCS/project.tex,v  --> project.tex
revision 1.1 (locked)

You now have a working copy you can modify with your editor. When you're done editing it, you check it in again to commit the changes:

$ ci project.tex
RCS/project.tex,v  <-- project.tex
new revision 1.2; previous revision: 1.1
enter log message, terminated with a single '.' or end of file:
>> (enter your description here)
>> .

If you want to change the version number, type ci -f2.0 project.tex.

Comparing versions

If you want to see the history of the changes in project.tex, issue

$ rlog project.tex

Using an old version

To extract an older version of your file (say, version 1.2 when you're working on 1.6), issue

$ co -r1.2 project.tex 

Be aware that this overwrites your existing working file, if you have one. You may do:

$ co -r1.2 -p project.tex > project.tex.1.2

10.3 Archiving: tar & gzip

Under UNIX there are some widely used applications to archive and compress files. tar is used to make archives, that is collections of files. To make a new archive:

$ tar -cvf <archive_name.tar> <file> [file...]

To extract files from an archive:

$ tar -xpvf <archive_name.tar> [file...]

To list the contents of an archive:

$ tar -tf <archive_name.tar> | less

Files can be compressed to save disk space using compress, which is obsolete and shouldn't be used any more, or gzip:

$ compress <file>
$ gzip <file>

that creates a compressed file with extension .Z (compress) or .gz (gzip). These programs don't make archives, but compress files individually. To decompress, use:

$ compress -d <file.Z>
$ gzip -d <file.gz>


The unarj, zip and unzip utilities are also available. Files with extension .tar.gz or .tgz (archived with tar, then compressed with gzip) are very common in the UNIX world. Here's how to list the contents of a .tar.gz archive:

$ gzip -dc <file.tar.gz> | tar tf - | less

To extract the files from a .tar.gz archive:

$ gzip -dc <file.tar.gz> | tar xvf -

Previous Next Contents