Archive for July, 2010

report-hw

Saturday, July 31st, 2010



SYNOPSIS
report-hw

DESCRIPTION
report-hw outputs a summary of the system’s hardware to standard out-
put. This hardware summary is aimed at diagnosing problems with hard-
ware autodection, or other problems during a Debian install, but can
also be useful to run on an installed system.

AUTHOR
The debian-installer team.

report-hw()

git-reflog

Friday, July 30th, 2010



SYNOPSIS
git reflog <subcommand> <options>

DESCRIPTION
The command takes various subcommands, and different options depending
on the subcommand:

git reflog expire [--dry-run] [--stale-fix] [--verbose]
[--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>…
git reflog delete ref@{specifier}…

git reflog [show] [log-options] [<ref>]

Reflog is a mechanism to record when the tip of branches are updated.
This command is to manage the information recorded in it.

The subcommand “expire” is used to prune older reflog entries. Entries
older than expire time, or entries older than expire-unreachable time
and are not reachable from the current tip, are removed from the
reflog. This is typically not used directly by the end users –
instead, see git-gc(1).

The subcommand “show” (which is also the default, in the absence of any
subcommands) will take all the normal log options, and show the log of
the reference provided in the command-line (or HEAD, by default). The
reflog will cover all recent actions (HEAD reflog records branch
switching as well). It is an alias for git log -g –abbrev-commit
–pretty=oneline; see git-log(1).

The reflog is useful in various git commands, to specify the old value
of a reference. For example, HEAD@{2} means “where HEAD used to be two
moves ago”, master@{one.week.ago} means “where master used to point to
one week ago”, and so on. See git-rev-parse(1) for more details.

To delete single entries from the reflog, use the subcommand “delete”
and specify the _exact_ entry (e.g. “git reflog delete master@{2}”).

OPTIONS
–stale-fix
This revamps the logic — the definition of “broken commit”
becomes: a commit that is not reachable from any of the refs and
there is a missing object among the commit, tree, or blob objects
reachable from it that is not reachable from any of the refs.

This computation involves traversing all the reachable objects,
i.e. it has the same cost as git prune. Fortunately, once this is
run, we should not have to ever worry about missing objects,
because the current prune and pack-objects know about reflogs and
protect objects referred by them.

–updateref
Update the ref with the sha1 of the top reflog entry (i.e.
<ref>@{0}) after expiring or deleting.

–rewrite
While expiring or deleting, adjust each reflog entry to ensure that
the old sha1 field points to the new sha1 field of the previous
entry.

–verbose
Print extra information on screen.

AUTHOR
Written by Junio C Hamano <gitster@pobox.com[1]>

DOCUMENTATION
Documentation by Junio C Hamano and the git-list
<git@vger.kernel.org[2]>.

GIT
Part of the git(1) suite

NOTES
1. gitster@pobox.com
mailto:gitster@pobox.com

2. git@vger.kernel.org
mailto:git@vger.kernel.org

Git 1.5.6.5 01/26/2010 GIT-REFLOG(1)

lzcat

Thursday, July 29th, 2010


SYNOPSIS
lzma [-123456789cdefhkLqtvV] [-S suffix] [filenames ...]
unlzma [-cfhkLqtvV] [-S suffix] [filenames ...]
lzcat [-fhLqV] [filenames ...]

DESCRIPTION
LZMA (Lempel-Ziv-Markov chain-Algorithm) is an improved version of
famous LZ77 compression algorithm. It was improved in way of maximum
increasing of compression ratio, keeping high decompression speed and
low memory requirements for decompressing.

lzma command line tool has a similar interface to gzip(1) and bzip2(1)
and is intended to make use of LZMA compression easy for the users who
are already familiar with gzip and bzip2.

In this manual lzma is compared mostly to bzip2 because that is cur-
rently one of the most widely used free software to compress tar files
made for distribution. Comparing lzma to gzip is not practical because
neither lzma nor bzip2 can compete with gzip in compression speed. On
the other hand the compression ratio of gzip is worse than of lzma and
bzip2.

lzma provides notably better compression ratio than bzip2 especially
with files having other than plain text content. The other advantage of
lzma is fast decompression which is many times quicker than bzip2. The
major disadvantage is that achieving the highest compression ratios
requires extensive amount of system resources, both CPU time and RAM.
Also software to handle LZMA compressed files is not installed by
default on most distributions.

When compressing or decompressing with lzma, the new file will have the
same ownership information, permissions and timestamps as the original
file. However the this information is not stored into the compressed
file like gzip does.

STREAMED VS. NON-STREAMED
LZMA files can be either streamed or non-streamed. Non-streamed files
are created only when the size of the file being compressed is known.
In practice this means that the source file must be a regular file. In
other words, if compressing from the standard input or from a named
pipe (fifo) the compressed file will always be streamed.

Both streamed and non-streamed files are compressed identically; the
only differences are found from the beginnings and ends of LZMA com-
pressed files: Non-streamed files contain the uncompressed size of the
file in the LZMA file header; streamed files have uncompressed size
marked as unknown. To know where to stop decoding, streamed files have
a special End Of Stream marker at the end of the LZMA file. The EOS
marker makes streamed files five or six bytes bigger than non-streamed.
as lzcat.

-d –decompress –uncompress
Force decompression regardless of the invocation name. This the
default when called as unlzma or lzcat.

-f –force
Force compression or decompression even if source file is a sym-
link, target exists, or target is a terminal. In contrast to
gzip and bzip2, if input data is not in LZMA format, –force
does not make lzma behave like cat. lzma never prompts if tar-
get file should be overwritten; existing files are skipped or,
in case of –force, overwritten.

-h –help
Show a summary of supported options and quit.

-k –keep
Do not delete the input files after compression or decompres-
sion.

-L –license
Show licensing information of lzma.

-q –quiet
Suppress all warnings. You can still check the exit status to
detect if a warning had been shown.

-S –suffix .suf
Use .suf instead of the default .lzma. A null suffix forces
unlzma to decompress all the given files regardless of the file-
name suffix.

-t –test
Check the integrity of the compressed file(s). Without –verbose
no output is produced if no errors are found.

-v –verbose
Show the filename and percentage reduction of each processes
file.

-V –version
Show the version number of lzma.

-z –compress
Force compression regardless of the invocation name.

-1 .. -9
Set the compression ratio. These options have no effect when
decompressing.

–fast Alias to -1.

AUTHORS
The LZMA algorithm and the implementation used in LZMA utils was devel-
oped by Igor Pavlov. The original code is available in LZMA SDK which
can be found from http://7-zip.org/sdk.html .

lzma command line tool was written by Ville Koskinen.
http://tukaani.org/lzma/

This manual page is inspired by manual pages of gzip and bzip2.

SEE ALSO
gzip(1), bzip2(1)

LZMA utils 23 Dec 2005 LZMA(1)

whiptail

Wednesday, July 28th, 2010



SYNOPSIS
whiptail [ --title title ] [ --backtitle backtitle ] [ --clear ] [
--default-item string ] [ --defaultno ] [ --fb ] [ --nocancel ] [
--noitem [ ] –output-fd fd ] [ --separate-output ] [ --scrolltext ]
box-options

DESCRIPTION
whiptail is a program that will let you present a variety of questions
or display messages using dialog boxes from a shell script. Currently,
these types of dialog boxes are implemented:

yes/no box, menu box, input box, message box, text box, info box,
checklist box, radiolist box gauge box, and password box.

OPTIONS
–clear
The screen will be cleared to the screen attribute on exit.
This doesn’t work in an xterm (and descendants) if alternate
screen switching is enabled, because in that case slang writes
to (and clears) an alternate screen.

–defaultno
The dialog box will open with the cursor over the No button.

–default-item string
Set the default item in a menu box. Normally the first item in
the box is the default.

–fb Use full buttons. (By default, whiptail uses compact buttons).

–nocancel
The dialog box won’t have a Cancel button.

–noitem
The menu, checklist and radiolist widgets will display tags
only, not the item strings.

–separate-output
For checklist widgets, output result one line at a time, with no
quoting. This facilitates parsing by another program.

–output-fd fd
Direct output to the given file descriptor. Most whiptail
scripts write to standard error, but error messages may also
be written there, depending on your script.

–title title
Specifies a title string to be displayed at the top of the dia-
log box.

–backtitle backtitle
Specifies a backtitle string to be displayed on the backdrop, at
This dialog box is useful for asking questions that require the
user to answer either yes or no. The dialog box has a Yes but-
ton and a No button, in which the user can switch between by
pressing the TAB key.

–msgbox text height width
A message box is very similar to a yes/no box. The only differ-
ence between a message box and a yes/no box is that a message
box has only a single OK button. You can use this dialog box to
display any message you like. After reading the message, the
user can press the ENTER key so that whiptail will exit and the
calling shell script can continue its operation.

–infobox text height width
An info box is basically a message box. However, in this case,
whiptail will exit immediately after displaying the message to
the user. The screen is not cleared when whiptail exits, so that
the message will remain on the screen until the calling shell
script clears it later. This is useful when you want to inform
the user that some operations are carrying on that may require
some time to finish.

–inputbox text height width [init]
An input box is useful when you want to ask questions that
require the user to input a string as the answer. If init is
supplied it is used to initialize the input string. When input-
ing the string, the BACKSPACE key can be used to correct typing
errors. If the input string is longer than the width of the dia-
log box, the input field will be scrolled. On exit, the input
string will be printed on stderr.

–passwordbox text height width [init]
A password box is similar to an input box, except the text the
user enters is not displayed. This is useful when prompting for
passwords or other sensitive information. Be aware that if any-
thing is passed in “init”, it will be visible in the system’s
process table to casual snoopers. Also, it is very confusing to
the user to provide them with a default password they cannot
see. For these reasons, using “init” is highly discouraged.

–textbox file height width
A text box lets you display the contents of a text file in a
dialog box. It is like a simple text file viewer. The user can
move through the file by using the UP/DOWN, PGUP/PGDN and
HOME/END keys available on most keyboards. If the lines are too
long to be displayed in the box, the LEFT/RIGHT keys can be used
to scroll the text region horizontally. For more convenience,
forward and backward searching functions are also provided.

–menu text height width menu-height [ tag item ] …
As its name suggests, a menu box is a dialog box that can be
used to present a list of choices in the form of a menu for the
state of each entry is specified by status. On exit, a list of
the tag strings of those entries that are turned on will be
printed on stderr.

–radiolist text height width list-height [ tag item status ] …
A radiolist box is similar to a menu box. The only difference
is that you can indicate which entry is currently selected, by
setting its status to on.

–gauge text height width percent
A gauge box displays a meter along the bottom of the box. The
meter indicates a percentage. New percentages are read from
standard input, one integer per line. The meter is updated to
reflect each new percentage. If stdin is XXX, then subsequent
lines up to another XXX are used for a new prompt. The gauge
exits when EOF is reached on stdin.

NOTES
whiptail interprets arguments starting with a dash “-” as being argu-
ments. To avoid this, and start some text in, for example, a menubox
item, with a dash, whiptail honours the getopt convention of accepting
the special argument “–” which means that all following arguments with
dashes are to be treated verbatim and not parsed as options.

DIAGNOSTICS
Exit status is 0 if whiptail is exited by pressing the Yes or OK but-
ton, and 1 if the No or Cancel button is pressed. Otherwise, if errors
occur inside whiptail or whiptail is exited by pressing the ESC key,
the exit status is -1.

AUTHOR
Based on the man page for dialog(1) by:

Savio Lam (lam836@cs.cuhk.hk) - version 0.3

Stuart Herbert (S.Herbert@sheffield.ac.uk) - patch for version 0.4

Modifications for whiptail by:

Enrique Zanardi (ezanard@debian.org)

Alastair McKinstry (mckinstry@debian.org)

Whiptail Version 0.51.6 20 September 2004 WHIPTAIL(1)

pnmtotiffcmyk

Tuesday, July 27th, 2010



SYNOPSIS
pnmtotiffcmyk [Compargs][Tiffargs][Convargs][ pnmfile ]

Compargs:
[-none|-packbits|-lzw [-predictor n]]

Tiffargs:
[-msb2lsb|-lsb2msb] [-rowsperstrip n]
[-lowdotrange n] [-highdotrange n]
[-knormal|-konly|-kremove]

Convargs:
[[-default][Defargs]|-negative]

Defargs:
[-theta deg] [-gamma n] [-gammap -1|-gammap n]

DESCRIPTION
Reads a portable anymap as input. Produces a CMYK encoded TIFF file as
output. Optionally modifies the colour balance and black level, and
removes CMY from under K.

OPTIONS
The order of most options is not important, but options for particular
conversion algorithms must appear after the algorithm is selected
(-default,-negative). If no algorithm is selected then -default is
assumed and the appropriate options (-theta,-gamma,-gammap) can appear
anywhere.

-none,-packbits,-lzw,-predictor
Tiff files can be compressed. By default LZW decompression is
used, but (apparently) some readers cannot read this, so you may
want to select a different algorithm (-none,-packbits). For LZW
compression, a -predictor value of 2 forces horizontal differ-
encing of scanlines before encoding; a value of 1 forces no dif-
ferencing.

-msb2lsb,-lsb2msb
These flags control fill order (default is -msb2lsb).

-rowsperstrip
This sets the number of rows in an image strip (data in the Tiff
files generated by this program is stored in strips - each strip
is compressed individually). The default gives a strip size of
no more than 8 kb.

-lowdotrange,-highdotrange
These options set tag values that may be useful for printers.
They have not been tested.

-knormal,-kremove,-konly
These options modify the values written to the Tiff file after

The CMYKTiff web site includes tests on the conversion parame-
ters. The test images illustrate the command line options in
practice and may make the following explanation clearer.

-theta deg
The basic conversion from RGB to CMY uses C = 1-R, M = 1-G, Y =
1-B. -theta provides a simple correction for any colour bias
that may occur in the printed image because, in practice, inks
do not exactly complement the primary colours. It rotates the
colours by the amount given (deg) in degrees. Unless you are
trying to produce unusual effects you will need to use small
values (try generating three images at -10, 0 (the default) and
10 degrees and seeing which has the best colour balance.

-gamma n
The black (K) component of the image is calculated as
min(C,Y,M). -gamma applies a gamma correction to this level.
In other words, the final black level is K (normalised to the
range 0 to 1) raised to the nth power. In practice this means
that a value greater than 1 makes the image lighter and a value
less than 1 makes the image darker. The range of allowed values
is 0.1 to 10.

-gammap n
This option controls the removal of CMY under K. If n is -1
then no removal occurs and C, M, Y and K are calculated as
above. This means that, when printed, dark areas contain all
four inks, which can make high contrast areas, like lettering,
appear fuzzy.

By default, when -gammap is not given on the command line, the
colours are reduced in dark areas by subtracting the black
level. The value subtracted is calculated with the same gamma
correction given by -gamma. Hopefully this will reduce fuzzi-
ness without changing the appearance of the image significantly.

If -gammap n is given, with n between 0.01 and 10, then black is
still subtracted, but the subtracted value is calculated using n
rather than any value supplied with -gamma. For example, it may
be best to only subtract black from the coloured inks in the
very darkest regions. In that case, n should be a large value,
such as 5.

BUGS
This program is not self-contained. It must be used with NetPbm and
libtiff must be available (libtiff is included in the 1mar94 release of
NetPbm).

SEE ALSO
pnmtotiff(1), tifftopnm(1), pnm(5)

Author: Patrick J. Naughton naughton@wind.sun.com

Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that copyright notice and this permission
notice appear in supporting documentation.

This file is provided AS IS with no warranties of any kind. The
author shall have no liability with respect to the infringement
of copyrights, trade secrets or any patents by this file or any
part thereof. In no event will the author be liable for any
lost revenue or profits or other special, indirect and conse-
quential damages.

9 December 1999 pnmtotiffcmyk(1)

ppmquant

Monday, July 26th, 2010


SYNOPSIS
ppmquant [-floyd|-fs] ncolors [ppmfile]
ppmquant [-floyd|-fs] [-nofloyd|-nofs] -mapfile mapfile [ppmfile]

All options can be abbreviated to their shortest unique prefix. You
may use two hyphens instead of one to designate an option. You may use
either white space or equals signs between an option name and its
value.

DESCRIPTION
pnmquant is a newer, more general program that is backward compatible
with ppmquant. ppmquant may be faster, though.

Reads a PPM image as input. Chooses ncolors colors to best represent
the image, maps the existing colors to the new ones, and writes a PPM
image as output.

The quantization method is Heckbert’s “median cut”.

Alternately, you can skip the color-choosing step by specifying your
own set of colors with the -mapfile option. The mapfile is just a ppm
file; it can be any shape, all that matters is the colors in it. For
instance, to quantize down to the 8-color IBM TTL color set, you might
use:
P3
8 1
255
0 0 0
255 0 0
0 255 0
0 0 255
255 255 0
255 0 255
0 255 255
255 255 255
If you want to quantize one image to use the colors in another one,
just use the second one as the mapfile. You don’t have to reduce it
down to only one pixel of each color, just use it as is.

If you use a mapfile, the output image has the same maxval as the map-
file. Otherwise, the output maxval is the same as the input maxval, or
less in some cases where the quantization process reduces the necessary
resolution.

The -floyd/-fs option enables a Floyd-Steinberg error diffusion step.
Floyd-Steinberg gives vastly better results on images where the unmodi-
fied quantization has banding or other artifacts, especially when going
to a small number of colors such as the above IBM set. However, it
does take substantially more CPU time, so the default is off.

AUTHOR
Copyright (C) 1989, 1991 by Jef Poskanzer.

12 January 1991 ppmquant(1)

jpegtopnm

Sunday, July 25th, 2010



SYNOPSIS
jpegtopnm [-dct {int|fast|float}] [-nosmooth] [-maxmemory N]
[{-adobe|-notadobe}] [-comments] [-dumpexif] [-exif=filespec] [-ver-
bose] [-tracelevel N] [ filename ]

All options may be abbreviated to their shortest unique prefix.

DESCRIPTION
jpegtopnm converts the named JFIF file, or the standard input if no
file is named to a PPM or PGM image file on the standard output. If
the JFIF file is of the grayscale variety, jpegtopnm generates a PGM
(Portable Graymap) file. Otherwise, it generates a PPM (Portable
Pixmap) file.

jpegtopnm uses the Independent JPEG Group’s JPEG library to interpret
the input file. See http://www.ijg.org for information on the library.

“JFIF” is the correct name for the image format commonly known as
“JPEG.” Strictly speaking, JPEG is a method of compression. The image
format using JPEG compression that is by far the most common is JFIF.
There is also a subformat of TIFF that uses JPEG compression.

EXIF is an image format that is a subformat of JFIF (to wit, a JFIF
file that contains an EXIF header as an APP1 marker). jpegtopnm han-
dles EXIF.

JFIF files can have either 8 bits per sample or 12 bits per sample.
The 8 bit variety is by far the most common. There are two versions of
the IJG JPEG library. One reads only 8 bit files and the other reads
only 12 bit files. You must link the appropriate one of these
libraries with jpegtopnm. Ordinarily, this means the library is in
your shared library search path when you run jpegtopnm.

jpegtopnm generates output with either one byte or two bytes per sample
depending on whether the JFIF input has either 8 bits or 12 bits per
sample. You can use pnmdepth to reduce a two-byte-per-sample file to a
one-byte-per-sample file if you need to.

If the JFIF file uses the CMYK or YCCK color space, the input does not
actually contain enough information to know what color each pixel is.
To know what color a pixel is, one would have to know the properties of
the inks to which the color space refers. jpegtopnm interprets the
colors using the common transformation which assumes all the inks are
simply subtractive and linear.

OPTIONS
The options are only for advanced users:

-dct int
-nosmooth
Use a faster, lower-quality upsampling routine.

-maxmemory N
Set limit on the amount of memory jpegtopnm uses in processing
large images. Value is in thousands of bytes, or millions of
bytes if “M” is suffixed to the number. For example, -maxmemory
4m selects 4000000 bytes. If jpegtopnm needs more space, it
uses temporary files.

-adobe

-notadobe
There are two variations on the CMYK (and likewise YCCK) color
space that may be used in the JFIF input. In the normal one, a
zero value for a color components indicates absence of ink. In
the other, a zero value means the maximum ink coverage. The
latter is used by Adobe Photoshop when it creates a bare JFIF
output file (but not when it creates JFIF output as part of
Encapsulated Postscript output).

These options tell jpegtopnm which version of the CMYK or YCCK
color space the image uses. If you specify neither, jpegtopnm
tries to figure it out on its own. In the present version, it
doesn’t try very hard at all: It just assumes the Photoshop ver-
sion, since Photoshop and its emulators seem to be the main
source of CMYK and YCCK images. But with experience of use,
future versions might be more sophisticated.

If the JFIF image does not indicate that it is CMYK or YCCK,
these options have no effect.

If you don’t use the right one of these options, the symptom is
output that looks like a negative.

-dumpexif
Print the interpreted contents of any Exif header in the input
file to the Standard Error file. Similar to the program jhead
(not part of the Netpbm package).

-exif=filespec
Extract the contents of the EXIF header from the input image and
write it to the file filespec. filespec = - means write it to
Standard Output. In this case, jpegtopnm does not output the
converted image at all.

jpegtopnm writes the contents of the EXIF header byte-for-byte,
starting with the two byte length field (which length includes
those two bytes).

You can use this file as input to ppmtojpeg to insert an identi-

-tracelevel n
Turn on the JPEG library’s trace messages to the Standard Error
file. A higher value of n gets more trace information. -ver-
bose implies a trace level of at least 1.

EXAMPLES
This example converts the color JFIF file foo.jpg to a PPM file named
foo.ppm:

jpegtopnm foo.jpg >foo.ppm

HINTS
You can use ppmquant to color quantize the result, i.e. to reduce the
number of distinct colors in the image. In fact, you may have to if
you want to convert the PPM file to certain other formats. ppmdither
Does a more sophisticated quantization.

Use pnmscale to change the dimensions of the resulting image.

Use ppmtopgm to convert a color JFIF file to a grayscale PGM file.

You can easily use these converters together. E.g.:

jpegtopnm foo.jpg | ppmtopgm | pnmscale .25
>foo.pgm

-dct fast and/or -nosmooth gain speed at a small sacrifice in quality.

If you are fortunate enough to have very fast floating point hardware,
-dct float may be even faster than -dct fast. But on most machines
-dct float is slower than -dct int; in this case it is not worth using,
because its theoretical accuracy advantage is too small to be signifi-
cant in practice.

Another program, djpeg, is similar. djpeg is maintained by the Inde-
pendent JPEG Group and packaged with the JPEG library which jpegtopnm
uses for all its JPEG work. Because of that, you may expect it to
exploit more current JPEG features. Also, since you have to have the
library to run jpegtopnm, but not vice versa, cjpeg may be more com-
monly available.

On the other hand, djpeg does not use the NetPBM libraries to generate
its output, as all the NetPBM tools such as jpegtopnm do. This means
it is less likely to be consistent with all the other programs that
deal with the NetPBM formats. Also, the command syntax of jpegtopnm is
consistent with that of the other Netpbm tools, unlike djpeg.

ENVIRONMENT
LIMITATIONS
Arithmetic coding is not supported for legal reasons.

The program could be much faster.

AUTHOR
jpegtopnm and this man page were derived in large part from djpeg, by
the Independent JPEG Group. The program is otherwise by Bryan Hender-
son on March 19, 2000.

19 March 2000 JPEGTOPNM(1)

red

Saturday, July 24th, 2010



SYNOPSIS
ed [-GVhs] [-p string] [file]

red [-GVhs] [-p string] [file]

DESCRIPTION
ed is a line-oriented text editor. It is used to create, display, mod-
ify and otherwise manipulate text files. red is a restricted ed: it
can only edit files in the current directory and cannot execute shell
commands.

If invoked with a file argument, then a copy of file is read into the
editor’s buffer. Changes are made to this copy and not directly to
file itself. Upon quitting ed, any changes not explicitly saved with
a `w’ command are lost.

Editing is done in two distinct modes: command and input. When first
invoked, ed is in command mode. In this mode commands are read from
the standard input and executed to manipulate the contents of the edi-
tor buffer. A typical command might look like:

,s/old/new/g

which replaces all occurrences of the string old with new.

When an input command, such as `a’ (append), `i’ (insert) or `c’
(change), is given, ed enters input mode. This is the primary means of
adding text to a file. In this mode, no commands are available;
instead, the standard input is written directly to the editor buffer.
Lines consist of text up to and including a newline character. Input
mode is terminated by entering a single period (.) on a line.

All ed commands operate on whole lines or ranges of lines; e.g., the
`d’ command deletes lines; the `m’ command moves lines, and so on. It
is possible to modify only a portion of a line by means of replacement,
as in the example above. However even here, the `s’ command is applied
to whole lines at a time.

In general, ed commands consist of zero or more line addresses, fol-
lowed by a single character command and possibly additional parameters;
i.e., commands have the structure:

[address [,address]]command[parameters]

The address(es) indicate the line or range of lines to be affected by
the command. If fewer addresses are given than the command accepts,
then default addresses are supplied.

OPTIONS
-G Forces backwards compatibility. Affects the commands `G’, `V’,
`f’, `l’, `m’, `t’, and `!!’.
the name with a backslash (\). The default filename is set to
file only if it is not prefixed with a bang.

LINE ADDRESSING
An address represents the number of a line in the buffer. ed maintains
a current address which is typically supplied to commands as the
default address when none is specified. When a file is first read,
the current address is set to the last line of the file. In general,
the current address is set to the last line affected by a command.

A line address is constructed from one of the bases in the list below,
optionally followed by a numeric offset. The offset may include any
combination of digits, operators (i.e. + and -) and whitespace.
Addresses are read from left to right, and their values are computed
relative to the current address.

One exception to the rule that addresses represent line numbers is the
address 0 (zero). This means “before the first line,” and is legal
wherever it makes sense.

An address range is two addresses separated either by a comma or semi-
colon. The value of the first address in a range cannot exceed the
value of the the second. If only one address is given in a range, then
the second address is set to the given address. If an n-tuple of
addresses is given where n > 2, then the corresponding range is deter-
mined by the last two addresses in the n-tuple. If only one address is
expected, then the last address is used.

Each address in a comma-delimited range is interpreted relative to the
current address. In a semicolon-delimited range, the first address is
used to set the current address, and the second address is interpreted
relative to the first.

The following address symbols are recognized.

. The current line (address) in the buffer.

$ The last line in the buffer.

n The nth, line in the buffer where n is a number in the range
[0,$].

- The previous line. This is equivalent to -1 and may be
repeated with cumulative effect.

to the address range 1,$.

; The current through last lines in the buffer. This is equiva-
lent to the address range .,$.

/re/ The next line containing the regular expression re. The search
wraps to the beginning of the buffer and continues down to the
current line, if necessary. // repeats the last search.

?re? The previous line containing the regular expression re. The
search wraps to the end of the buffer and continues up to the
current line, if necessary. ?? repeats the last search.

‘lc The line previously marked by a `k’ (mark) command, where lc is
a lower case letter.

REGULAR EXPRESSIONS
Regular expressions are patterns used in selecting text. For example,
the ed command

g/string/

prints all lines containing string. Regular expressions are also used
by the `s’ command for selecting old text to be replaced with new.

In addition to a specifying string literals, regular expressions can
represent classes of strings. Strings thus represented are said to be
matched by the corresponding regular expression. If it is possible for
a regular expression to match several strings in a line, then the left-
most longest match is the one selected.

The following symbols are used in constructing regular expressions:

c Any character c not listed below, including `{’, ‘}’, `(’, `)’,
`<’ and `>’, matches itself.

\c A backslash-escaped character c other than `{’, ‘}’, `(’, `)’,
`<’, `>’, `b’, ‘B’, `w’, `W’, `+’, and `?’ matches itself.

. Matches any single character.

[char-class]
Matches any single character in char-class. To include a `]’
Patterns in char-class of the form:

[.col-elm.] or, [=col-elm=]

where col-elm is a collating element are interpreted according
to locale(5) (not currently supported). See regex(3) for an
explanation of these constructs.

[^char-class]
Matches any single character, other than newline, not in char-
class. char-class is defined as above.

^ If `^’ is the first character of a regular expression, then it
anchors the regular expression to the beginning of a line.
Otherwise, it matches itself.

$ If `$’ is the last character of a regular expression, it
anchors the regular expression to the end of a line. Other-
wise, it matches itself.

\(re\) Defines a (possibly null) subexpression re. Subexpressions may
be nested. A subsequent backreference of the form `\n’, where
n is a number in the range [1,9], expands to the text matched
by the nth subexpression. For example, the regular expression
`\(a.c\)\1′ matches the string `abcabc’, but not `abcadc’.
Subexpressions are ordered relative to their left delimiter.

* Matches the single character regular expression or subexpres-
sion immediately preceding it zero or more times. If ‘*’ is
the first character of a regular expression or subexpression,
then it matches itself. The `*’ operator sometimes yields
unexpected results. For example, the regular expression `b*’
matches the beginning of the string `abbb’, as opposed to the
substring `bbb’, since a null match is the only left-most
match.

\{n,m\}
\{n,\}
\{n\} Matches the single character regular expression or subexpres-
sion immediately preceding it at least n and at most m times.
If m is omitted, then it matches at least n times. If the
comma is also omitted, then it matches exactly n times. If
any of these forms occurs first in a regular expression or
subexpression, then it is interpreted literally (i.e., the reg-
ular expression `\{2\}’ matches the string `{2}’, and so on).

\<
\> Anchors the single character regular expression or subexpres-
sion immediately following it to the beginning (\<) or ending
(\>) of a word, i.e., in ASCII, a maximal string of alphanu-
meric characters, including the underscore (_).

\+ Matches the single character regular expression or subexpres-
sion immediately preceding it one or more times. So the regu-
lar expression `a\+’ is shorthand for `aa*’. If \+ occurs at
the beginning of a regular expression or subexpression, then it
matches a literal `+’.

\b Matches the beginning or ending (null string) of a word. Thus
the regular expression `\bhello\b’ is equivalent to
`\<hello\>’. However, `\b\b’ is a valid regular expression
whereas `\<\>’ is not.

\B Matches (a null string) inside a word.

\w Matches any character in a word.

\W Matches any character not in a word.

COMMANDS
All ed commands are single characters, though some require additional
parameters. If a command’s parameters extend over several lines, then
each line except for the last must be terminated with a backslash (\).

In general, at most one command is allowed per line. However, most
commands accept a print suffix, which is any of `p’ (print), `l’ (list)
, or `n’ (enumerate), to print the last line affected by the command.

An interrupt (typically ^C) has the effect of aborting the current com-
mand and returning the editor to command mode.

ed recognizes the following commands. The commands are shown together
with the default address or address range supplied if none is specified
(in parenthesis).

(.)a Appends text to the buffer after the addressed line, which may
be the address 0 (zero). Text is entered in input mode. The
current address is set to last line entered.

(.,.)c Changes lines in the buffer. The addressed lines are deleted
from the buffer, and text is appended in their place. Text is
entered in input mode. The current address is set to last line
entered.

(.,.)d Deletes the addressed lines from the buffer. If there is a
line after the deleted range, then the current address is set
to this line. Otherwise the current address is set to the line
before the deleted range.

e file Edits file, and sets the default filename. If file is not
specified, then the default filename is used. Any lines in
the buffer are deleted before the new file is read. The cur-
rent address is set to the last line read.

(1,$)g/re/command-list
Applies command-list to each of the addressed lines matching a
regular expression re. The current address is set to the line
currently matched before command-list is executed. At the end
of the `g’ command, the current address is set to the last line
affected by command-list.

Each command in command-list must be on a separate line, and
every line except for the last must be terminated by a back-
slash (\). Any commands are allowed, except for `g’, `G’, `v’,
and `V’. A newline alone in command-list is equivalent to a
`p’ command.

(1,$)G/re/
Interactively edits the addressed lines matching a regular
expression re. For each matching line, the line is printed,
the current address is set, and the user is prompted to enter a
command-list. At the end of the `G’ command, the current
address is set to the last line affected by (the last) command-
list.

The format of command-list is the same as that of the `g’ com-
mand. A newline alone acts as a null command list. A single
`&’ repeats the last non-null command list.

H Toggles the printing of error explanations. By default, expla-
nations are not printed. It is recommended that ed scripts
begin with this command to aid in debugging.

h Prints an explanation of the last error.

(.)i Inserts text in the buffer before the current line. Text is
entered in input mode. The current address is set to the last
line entered.

(.,.+1)j
Joins the addressed lines. The addressed lines are deleted
from the buffer and replaced by a single line containing their
joined text. The current address is set to the resultant line.

(.)klc Marks a line with a lower case letter lc. The line can then
be addressed as ‘lc (i.e., a single quote followed by lc ) in
subsequent commands. The mark is not cleared until the line is
deleted or otherwise modified.

(.,.)l Prints the addressed lines unambiguously. If invoked from a
terminal, ed pauses at the end of each page until a newline is
entered. The current address is set to the last line printed.

(.,.)m(.)
Moves lines in the buffer. The addressed lines are moved to
after the right-hand destination address, which may be the

q Quits ed.

Q Quits ed unconditionally. This is similar to the q command,
except that unwritten changes are discarded without warning.

($)r file
Reads file to after the addressed line. If file is not speci-
fied, then the default filename is used. If there was no
default filename prior to the command, then the default file-
name is set to file. Otherwise, the default filename is
unchanged. The current address is set to the last line read.

($)r !command
Reads to after the addressed line the standard output of `!com-
mand’, (see the !command below). The default filename is
unchanged. The current address is set to the last line read.

(.,.)s/re/replacement/
(.,.)s/re/replacement/g
(.,.)s/re/replacement/n
Replaces text in the addressed lines matching a regular expres-
sion re with replacement. By default, only the first match in
each line is replaced. If the `g’ (global) suffix is given,
then every match to be replaced. The `n’ suffix, where n is a
positive number, causes only the nth match to be replaced. It
is an error if no substitutions are performed on any of the
addressed lines. The current address is set the last line
affected.

re and replacement may be delimited by any character other than
space and newline (see the `s’ command below). If one or two
of the last delimiters is omitted, then the last line affected
is printed as though the print suffix `p’ were specified.

An unescaped `&’ in replacement is replaced by the currently
matched text. The character sequence `\m’, where m is a number
in the range [1,9], is replaced by the mth backreference
expression of the matched text. If replacement consists of a
single `%’, then replacement from the last substitution is
used. Newlines may be embedded in replacement if they are
escaped with a backslash (\).

(.,.)s Repeats the last substitution. This form of the `s’ command
accepts a count suffix `n’, or any combination of the charac-
ters `r’, `g’, and `p’. If a count suffix `n’ is given, then
only the nth match is replaced. The `r’ suffix causes the reg-
ular expression of the last search to be used instead of the
that of the last substitution. The `g’ suffix toggles the
global suffix of the last substitution. The `p’ suffix toggles
the print suffix of the last substitution. The current address
is set to the last line affected.
mand.

(1,$)V/re/
Interactively edits the addressed lines not matching a regular
expression re. This is similar to the `G’ command.

(1,$)w file
Writes the addressed lines to file. Any previous contents of
file is lost without warning. If there is no default filename,
then the default filename is set to file, otherwise it is
unchanged. If no filename is specified, then the default file-
name is used. The current address is unchanged.

(1,$)wq file
Writes the addressed lines to file, and then executes a `q’
command.

(1,$)w !command
Writes the addressed lines to the standard input of `!command’,
(see the !command below). The default filename and current
address are unchanged.

(1,$)W file
Appends the addressed lines to the end of file. This is simi-
lar to the `w’ command, expect that the previous contents of
file is not clobbered. The current address is unchanged.

(.)x Copies (puts) the contents of the cut buffer to after the
addressed line. The current address is set to the last line
copied.

(.,.)y Copies (yanks) the addressed lines to the cut buffer. The cut
buffer is overwritten by subsequent `y’, `s’, `j’, `d’, or `c’
commands. The current address is unchanged.

(.+1)zn Scrolls n lines at a time starting at addressed line. If n is
not specified, then the current window size is used. The cur-
rent address is set to the last line printed.

!command
Executes command via sh(1). If the first character of command
is `!’, then it is replaced by text of the previous `!command’.
ed does not process command for backslash (\) escapes. How-
ever, an unescaped `%’ is replaced by the default filename.
When the shell returns from execution, a `!’ is printed to the
standard output. The current line is unchanged.

(.,.)# Begins a comment; the rest of the line, up to a newline, is
ignored. If a line address followed by a semicolon is given,
then the current address is set to that address. Otherwise,
the current address is unchanged.

B. W. Kernighan and P. J. Plauger, Software Tools in Pascal , Addison-
Wesley, 1981.

LIMITATIONS
ed processes file arguments for backslash escapes, i.e., in a file-
name, any characters preceded by a backslash (\) are interpreted liter-
ally.

If a text (non-binary) file is not terminated by a newline character,
then ed appends one on reading/writing it. In the case of a binary
file, ed does not append a newline on reading/writing.

per line overhead: 4 ints

DIAGNOSTICS
When an error occurs, if ed’s input is from a regular file or here doc-
ument, then it exits, otherwise it prints a `?’ and returns to command
mode. An explanation of the last error can be printed with the `h’
(help) command.

Attempting to quit ed or edit another file before writing a modified
buffer results in an error. If the command is entered a second time,
it succeeds, but any changes to the buffer are lost.

ed exits with 0 if no errors occurred; otherwise >0.

5 October 2006 ED(1)

chkdupexe

Friday, July 23rd, 2010



SYNOPSIS
chkdupexe

DESCRIPTION
chkdupexe will scan the union of $PATH and a hardcoded list of common
locations for binaries. It will report dangling symlinks and dupli-
cately-named binaries.

AUTHOR
Nicolai Langfeldt, Michael Shields.

11 Mar 1995 CHKDUPEXE(1)

eps2eps

Thursday, July 22nd, 2010



SYNOPSIS
ps2ps [ options ] input.ps output.ps
eps2eps [ options ] input.eps output.eps

DESCRIPTION
ps2ps uses gs(1) to convert PostScript(tm) file “input.ps” to simpler,
normalized and (usually) faster PostScript in “output.ps”. Normally
the output is allowed to use PostScript Level 2 or Level 3 constructs,
but the -dLanguageLevel=1 option restricts the output to Level 1.

eps2eps performs the equivalent optimization for Encapsulated
PostScript (EPS) files.

Both accept any general Ghostscript command line options, and respec-
tively options specific to the pswrite and epswrite devices.

FILES
Run “gs -h” to find the location of Ghostscript documentation on your
system, from which you can get more details.

BUGS
The pswrite device used by both ps2ps and eps2eps produces much lower
level output than is desirable. Use with caution.

SEE ALSO
ps2pdf(1), ps2ascii(1), ps2epsi(1)

VERSION
This document was last revised for Ghostscript version 8.62.

AUTHOR
Artifex Software, Inc. are the primary maintainers of Ghostscript.

8.62 29 February 2008 PS2PS(1)