NEXT UP previous
Next: Dos Files

Other Tools

There are several other tools available under Linux that are worth mentioning at this time. The first of these is the pr command. The function of this command is to split a file up into pages of the correct size to send to a printer. By default, the pages have a heading inserted which contains the date and time, the file name and the page number:

	$ pr pw.test

	Jun 1 09:20 1995 pw.test Page 1

	root:awmku76tr43d6:0:0::/root/:/bin/sh
	pc:bdhd74hs9jh3h:500:50::/usr1/pc:/bin/bash
	carey:esJ9ohd8HH89i:501:50::/usr1/carey:/bin/bash
	mot:dhjd83kjdJS6D:1500:60::/usr1/mot:/bin/bash 
	grex:cj8AjoWE8h8fs:1500:60::/usrl/mot:/bin/sh

It is also possible to use the -n command line switch to get the pr command to add line numbers to the text:

	$ pr -n pw.test

	Jun 1 09:20 1995 pw.test Page 1

	1 root:awmku76tr43d6:0:0::/root1:/bin/sh
	2 pc:bdhd74hs9jh3h:500:50::/usr1/pc:/bin/bash
	3 carey:esJ9ohd8HH89i:501:50::/usr1/carey:/bin/bash
	4 mot:dhjd83kjdJS6D:1500:60::/usr1/mot:/bin/bash
	5 grex:cj8AjoWE8h8fs:1500:60::/usr1/mot:/bin/sh 

The next command to look at is called od. This command allows you to examine the contents of a text or data file as a set of bytes. Each line of output consists of a number which is the current byte offset into the file followed by a set of sixteen byte values. All the data byte and offset values in the output can be displayed in several formats, including ASCII characters, and octal or hexadecimal numbers:

	$ od /tmp/text/motd
	0000000 064514 072556 020170 027061 027062 027061 024040 047520
	0000020 044523 024530 005056
	0000026

The default display from od is all in octal, which is where it gets its name from (Octal Dump). This is not usually the most useful display however, and a more informative output can be created with the display set, for instance, to a combination of ASCII characters and hexadecimal values:

	$ od -Ax -tCxl /tmp/text/motd
	000000 	m  o  t  d     c  o  n  t  a  n  t  s     i  n
               6d 6f 74 64 20 63 6f 6a 74 65 6e 74 73 20 69 6e
	000010     h  e  r  e  . \n
               20 68 65 72 65 2e Oa
	000017

The -A switch allows you to specify what format to use for the offset values. The choices are:

xhexadecimal;
ooctal (default);
ddecimal;
nno offset output.

The -t switch lets you specify one or more formats in which to display the byte values in the file. The main choices here are:

xnhexadecimal;
onoctal (o2 is default);
dnsigned decimal;
ununsigned decimal;
CASCII character or backslash sequence.

The number given for n specifies how many bytes to use for each value displayed. Other options for this command are explained in the associated manual page.

The final command in this section is called file. The purpose of this command in to give you some information about another file to help you to classify its contents. The file command runs through a set of tests to try to identify a file's type and stops to print a message as soon as it thinks it has a positive identification. Due to the nature of some of the tests, it is possible for file to be fooled, but this is rare and should not present any major problems:

	$ file * 
	book.dvi:	TeX DVI file data
	book.log:	TeX transcript text
	book.ps:	PostScript document
	book.tex:	English text
	fdr:		ascii text
	inc:		directory

NEXT UP previous
Next: Dos Files