2.2. Alphabetical Summary of Common Commands

 < Day Day Up > 

This list describes the commands that are common to two or more of Solaris, GNU/Linux, and Mac OS X. It also includes many programs available from the Internet that may not come "out of the box" on all the systems.

On Solaris, many of the Free Software and Open Source programs described here may be found in /usr/sfw/bin or /opt/sfw/bin. Interestingly, the Intel version of Solaris has more programs in /opt/sfw/bin than does the SPARC version. As mentioned earlier, on Solaris, we recommend placing /usr/xpg6/bin and /usr/xpg4/bin in your PATH before /usr/bin.

aclocal

     aclocal [options]

Part of GNU automake. Place m4 macro definitions needed by autoconf into a single file. The aclocal command first scans for macro definitions in m4 files in its default directory (/usr/share/aclocal on some systems) and in the file acinclude.m4. It next scans for macros used in the configure.ac file. It generates an aclocal.m4 file that contains definitions of all m4 macros required by autoconf. See also automake.

Options


--acdir=dir

Look for macro files in directory dir instead of the default directory.


--force

Always update the output file.


-I dir

Additionally, search directory dir for m4 macro definitions.


--output=file

Save output to file instead of aclocal.m4.


--print-ac-dir

Print the name of the directory to be searched for m4 files, then exit.


--verbose

Print names of files being processed.

apropos

     apropos keywords

Look up one or more keywords in the online manpages. Same as man -k. See also whatis.

ar

     ar key [args] [posname] [count] archive[files]

Maintain a group of files that are combined into a file archive. Used most commonly to create and update library files as used by the loader (ld). Only one key letter can be used, but each may be combined with additional args (with no separations between). posname is the name of a file in archive. When moving or replacing files, you can specify that they be placed before or after posname.

On all three systems, key and args can be preceded with a -, as though they were regular options.

Solaris: ar is found in /usr/ccs/bin.

Key

d

Delete files from archive.

m

Move files to end of archive.

p

Print files in archive.

q

Append files to archive.

r

Replace files in archive.

t

List the contents of archive or list the named files.

x

Extract contents from archive or only the named files.


Common Arguments

a

Use with r or m to place files in the archive after posname.

b

Same as a but before posname.

c

Create archive silently.

i

Same as b.

s

Force regeneration of archive symbol table (useful after running strip).

u

Use with r to replace only files that have changed since being put in archive.

v

Verbose; print a description.


Solaris and GNU/Linux Argument

V

Print version number.


Solaris and Mac OS X Argument

T

Truncate long filenames when extracting onto filesystems that don't support long filenames. Without this operation, extracting files with long filenames is an error.


Solaris Argument

C

Don't replace existing files of the same name with the one extracted from the archive. Useful with T.


GNU/Linux Arguments

f

Truncate long filenames.

N

Use the count parameter. Where multiple entries with the same name are found, use the count instance.

o

Preserve original timestamps.

P

Use full pathname. Useful for non-POSIX-compliant archives.

S

Do not regenerate the symbol table.


Mac OS X Argument

L

Provide support for long filenames. This is the default.


Example

Update the versions of object files in mylib.a with the ones in the current directory. Only files in the mylib.a that are also in the current directory are replaced.

     ar r mylib.a *.o

as

     as [options] files

Generate an object file from each specified assembly language source file. Object files have the same rootname as source files but replace the .s suffix with .o. as is usually called by compiler driver programs such as cc or gcc.

Each system has options specific to it, often too many options to comprehend easily. See your local as(1) manpage.

Solaris: as is found in /usr/ccs/bin.

Common Option


-o objfile

Place output in object file objfile (default is file.o).

at

     at options1 time [date] [+ increment]     at options2 [jobs]

Execute commands entered on standard input at a specified time and optional date. (See also batch and crontab.) End input with EOF. time can be formed either as a numeric hour (with optional minutes and modifiers) or as a keyword. date can be formed either as a month and date, as a day of the week, or as a special keyword. increment is a positive integer followed by a keyword. See the following lists for details.

Common Options1


-f file

Execute commands listed in file.


-m

Send mail to user after job is completed.

Solaris Options1


-c

Use the C shell to execute the job.


-k

Use the Korn shell to execute the job.


-p project

Schedule the job under project.


-q queuename

Schedule the job in queuename. Values for queuename are the lowercase letters a through z. Queue a is the default queue for at jobs. Queue b is the queue for batch jobs. Queue c is the queue for cron jobs.


-s

Use the Bourne shell to execute the job.


-t time

Run the job at time, which is in the same format as allowed by touch.

GNU/Linux Options1


-c

Display the specified jobs on the standard output. This option does not take a time specification.


-V

Display the version number.

Common Options2


-l

Report all jobs that are scheduled for the invoking user or, if jobs are specified, report only for those. See also atq.

Solaris and Mac OS X Options2


-r

Remove specified jobs that were previously scheduled. To remove a job, you must be a privileged user or the owner of the job. Use -l first to see the list of scheduled jobs. See also atrm.

GNU/Linux Options2


-d

Same as Solaris or Mac OS X -r.

Time


hh: mm [ modifiers]

Hours can have one or two digits (a 24-hour clock is assumed by default); optional minutes can be given as one or two digits; the colon can be omitted if the format is h, hh, or hhmm; e.g., valid times are 5, 5:30, 0530, 19:45. If modifier am or pm is added, time is based on a 12-hour clock. If the keyword zulu is added, times correspond to Greenwich Mean Time (UTC).


midnight|noon|now

Use any one of these keywords in place of a numeric time. now must be followed by an increment.

Date


month num[, year]

month is one of the 12 months, spelled out or abbreviated to their first three letters; num is the calendar day of the month; year is the four-digit year. If the given month occurs before the current month, at schedules that month next year.


day

One of the seven days of the week, spelled out or abbreviated to their first three letters.


today|tomorrow

Indicate the current day or the next day. If date is omitted, at schedules today when the specified time occurs later than the current time; otherwise, at schedules tomorrow.

Increment

Supply a numeric increment if you want to specify an execution time or day relative to the current time. The number should precede any of the keywords minute, hour, day, week, month, or year (or their plural forms). The keyword next can be used as a synonym for + 1.

Examples

In typical usage, you run at and input commands that you want executed at a particular time, followed by EOF. The GNU/Linux version prompts for input with at>; the other systems do not.

     $ at 1:00 am tomorrow      at> ./total_up > output      at> mail joe < output      at> <EOT>              Entered by pressing CTRL-D     job 1 at 2003-03-19 01:00

The two commands could also be placed in a file and submitted as follows:

     $ at 1:00 am tomorrow < scriptfile

More examples of syntax follow. Note that the first two commands are equivalent.

     at 1945 pm December 9     at 7:45pm Dec 9     at 3 am Saturday     at now + 5 hours     at noon next day

atq

     atq [options] [users]

List jobs created by the at command that are still in the queue. Normally, jobs are sorted by the order in which they execute. Specify the users whose jobs you want to check. If no users are specified, the default is to display all jobs if you're a privileged user; otherwise, only your jobs are displayed.

Solaris Options


-c

Sort the queue according to the time the at command was given.


-n

Print only the total number of jobs in queue.

GNU/Linux and Mac OS X Option


-q queue

Show the jobs in queue queue.

GNU/Linux Option


-V

Print the version number to standard error.

Mac OS X Option


-v

Show jobs that are completed but not yet removed from the queue.

atrm

     atrm [options] [users | jobIDs]

Remove jobs queued with at that match the specified jobIDs. A privileged user may also specify the users whose jobs are to be removed.

Solaris Options


-a

Remove all jobs belonging to the current user. (A privileged user can remove all jobs.)


-f

Remove jobs unconditionally, suppressing all information regarding removal.


-i

Prompt for y (remove the job) or n (do not remove).

GNU/Linux and Mac OS X Option


-q queue

Remove the jobs in queue queue.

GNU/Linux Option


-V

Print the version number to standard error.

autoconf

     autoconf [options] [template_file]

Generate a configuration script from m4 macros defined in template_file, if given, or in a configure.ac or configure.in file in the current working directory. The generated script is almost invariably called configure.

Other related programs come as part of autoconf. They are usually invoked automatically by tools in the autoconf suite. They are:

autoreconf

Update configure scripts by running autoconf, autoheader, aclocal, automake, and libtoolize as needed.

autoscan

Create or maintain a preliminary configure.ac file named configure.scan based on source files in specified directory, or the current directory if none given.

autoupdate

Update the configure template file file, or configure.ac if no file is specified.


URL: http://www.gnu.org/software/autoconf.

Options


-d, --debug

Don't remove temporary files.


-f, --force

Replace files generated previously by autoconf.


-i, --initialization

When tracing calls with the -t option, report calls made during initialization.


-I dir, --include=dir

Search in directory dir for input files.


-o file, --output=file

Save output to file.


-t macro, --trace=macro

Report the list of calls to macro.


-v, --verbose

Verbosely print information about the progress of autoconf.


-W category, --warnings=category

Print any warnings related to category. Accepted categories are:

all

All warnings.

cross

Cross compilation.

error

Treat warnings as errors.

no-category

Turn off warnings for category.

none

Turn off all warnings.

obsolete

Obsolete constructs.

syntax

Questionable syntax.


autoheader

     autoheader [options] [template_file]

Part of GNU autoconf. Generate a template file of C #define statements from m4 macros defined in template_file, if given, or in a configure.ac or configure.in file in the current working directory. The generated template file is almost invariably called config.h.in or config.hin.

Options


-B dir, --prepend-include=dir

Prepend directory dir to the search path for input files.


-d, --debug

Don't remove temporary files.


-f, --force

Replace files generated previously by autoheader.


-I dir, --include=dir

Append directory dir to the search path for input files.


-o file, --output=file

Save output to file.


-v, --verbose

Verbosely print information about the progress of autoheader.


-V, --version

Print version number, then exit.


-W category, --warnings=category

Print any warnings related to category. Accepted categories are:

all

All warnings.

cross

Cross compilation.

error

Treat warnings as errors.

gnu

GNU coding standards.

no-category

Turn off warnings for category.

none

Turn off all warnings.

obsolete

Obsolete constructs.

override

User redefinitions of automake variables or rules.

portability

Portability issues.

syntax

Questionable syntax.

unsupported

Unsupported or incomplete features.


automake

     automake [options] [template_file]

GNU automake tool. Creates GNU standards-compliant Makefile.in files from Makefile.am template files and can be used to ensure that projects contain all the files and installation options required to be standards-compliant.

URL: http://www.gnu.org/software/automake.

Options


-a, --add-missing

Add any missing files automake requires to the directory by creating symbolic links to automake's default versions.


-c, --copy

Used with the -a option. Copy missing files instead of creating symbolic links.


--cygnus

Specifies that the project has a Cygnus-style source tree.


-f, --force-missing

Used with the -a option. Replace required files even if a local copy already exists.


--foreign

Treat project as a non-GNU project. Check only for elements required for proper operation.


--gnits

A stricter version of --gnu, performing more checks to comply with GNU project structure rules.


--gnu

Treat project as a GNU project with the GNU project structure.


-i, --ignore-deps

Disable automatic dependency tracking.


--include-deps

Enable automatic dependency tracking.


--libdir=dir

Used with the -a option. Search in directory dir for default files.


--no-force

Update only Makefile.in files that have updated dependents.


-v, --verbose

List files being read or created by automake.


-W category, --warnings=category

Print any warnings related to category. Accepted categories are:

all

All warnings.

error

Treat warnings as errors.

gnu

GNU coding standards.

no-category

Turn off warnings for category.

none

Turn off all warnings.

obsolete

Obsolete constructs.

override

User redefinitions of automake variables or rules.

portability

Portability issues.

syntax

Questionable syntax.

unsupported

Unsupported or incomplete features.


awk

     awk [options] [program] [var=value ...] [files]

Use the pattern-matching program to process the specified files. program instructions have the general form:

     pattern { procedure }

pattern and procedure are optional. When specified on the command line, program must be enclosed in single quotes to prevent the shell from interpreting its special symbols.

Two versions of awk exist: the original, "old" awk from V7 Unix, circa 1979, and "new" awk, from System V Release 4. POSIX awk is based on the new one.

On most systems, awk is a POSIX-compliant version, except on Solaris, where you must use /usr/xpg4/bin/awk instead of /usr/bin/awk. Some systems provide oawk and nawk commands as well. See Chapter 11 for more information (including examples) on awk.

banner

     banner characters

Print characters as a poster on the standard output. Each word supplied must contain 10 characters or less.

The figlet program is more useful and flexible (http://www.figlet.org).

basename

     basename pathname [suffix]     basename [-a] [-s suffix] pathname ...

Given a pathname, strip the path prefix and leave just the filename, which is printed on standard output. If specified, a filename suffix (e.g., .c) is removed also. basename is typically invoked via command substitution ('...') to generate a filename. See also dirname.

Solaris: The version of basename in /usr/bin allows the suffix to be a pattern of the form accepted by expr. See the entry for expr for more details. The version is /usr/xpg4/bin does not treat the suffix specially.

The second syntax is for Mac OS X.

Mac OS X Options


-a

Treat every argument as a pathname, removing the leading components.


-s suffix

Use suffix as the suffix to remove from each following pathname.

Example

Given the following fragment from a Bourne shell script:

     ofile=output_file     myname="'basename $0'"     echo "$myname: QUITTING: can't open $ofile" 1>&2     exit 1

If the script is called do_it, the following message would be printed on standard error:

     do_it: QUITTING: can't open output_file

bash

     bash [options] [file [arguments]]     sh [options] [file [arguments]]

Bash is the GNU Project's Bourne Again shell. On GNU/Linux systems and Mac OS X, it is the standard shell, doing double duty as /bin/sh. It is also supplied with Solaris. For more information, see Chapter 4.

URL: http://www.gnu.org/software/bash.

batch

     batch [options] [time]

Execute commands entered on standard input. End with EOF. Unlike at, which executes commands at a specific time, batch executes commands one after another (waiting for each one to complete). This avoids the potentially high system load caused by running several background jobs at once. The GNU/Linux and Mac OS X versions allow you to specify time, which is when the job should run. See also at.

On Solaris, batch is equivalent to at -q b -m now. It takes no arguments, reading commands from standard input. Instead of the original System V version, Mac OS X uses an earlier version of the same batch command found on GNU/Linux. The GNU/Linux version has more options.

On Mac OS X, at, atq, atrm and batch are disabled by default. See the at(1) manpage for more information.


Solaris Option


-p project

Run the job under project project.

GNU/Linux and Mac OS X Options


-f file

Read the job commands from file instead of from standard input.


-m

Send mail to the user when the job is done.

GNU/Linux Options


-q queue

Use job queue queue. See the entry for at for more information.


-v

Show the time when the job will run.


-V

Print version information to standard error before reading the job.

Example

$ batch      sort data.raw > data.sorted      troff -Tps -mm thesis.mm > bigfile.ps       EOF

bc

     bc [options] [files]

Interactively perform arbitrary-precision arithmetic or convert numbers from one base to another. Input can be taken from files or read from the standard input. To exit, type quit or EOF.

bc is a language (and compiler) whose syntax resembles that of C, but with unlimited-precision arithmetic. bc consists of identifiers, keywords, and symbols. Examples are given at the end. GNU/Linux and Mac OS X both use GNU bc.

URL: http://www.gnu.org/software/bc/.

Common Option


-l, --mathlib

Make functions from the math library available. This is the only option required by POSIX.

Solaris Options


-c

Do not invoke dc; compile only. (On Solaris, and on most commercial Unix systems, bc is a preprocessor for dc, so bc normally invokes dc.)

GNU bc Options


-h, --help

Print help message and exit.


-i, --interactive

Interactive mode.


-q, --quiet

Do not display welcome message.


-s, --standard

Ignore all extensions, and process exactly as in POSIX.


-v, --version

Print version number.


-w, --warn

When extensions to POSIX bc are used, print a warning.

Examples

Note in these examples that when you type some quantity (a number or expression), it is evaluated and printed, but assignment statements produce no display:

     $ bc                Stat the program     ibase = 8           Octal input     20                  Evaluate this octal number     16                 Terminal displays decimal value     obase = 2           Display output in base 2 instead of base 10     20                  Octal input     10000              Terminal now displays binary value     ibase = A           Restore base 10 input     scale = 3           Truncate results to three places     8/7                 Evaluate a division     1.001001000        Oops! Forgot to reset output base to 10     obase = 10          Input is decimal now, so "A" isn't needed     8/7      1.142              Terminal displays result (truncated)

The following lines show the use of functions:

     $ bc                Start the program     define p(r,n){      Function p uses two arguments       auto v            v is a local variable       v = r^n           r raised to the n power       return(v)}        Value returned     scale = 5      x = p(2.5,2)        x = 2.5 ^ 2     x                   Print value of x     6.25     length(x)           Number of digits     3     scale(x)            Number of places to right of decimal point     2

biff

     biff [y | n]

Turn mail notification on or off. With no arguments, biff indicates the current status.

When mail notification is turned on, each time you get incoming mail, the bell rings, and the first few lines of each message are displayed.

Solaris: This command is in /usr/ucb.

bison

     bison [options] file

Given a file containing a context-free grammar, convert it into tables for subsequent parsing while sending output to file.c. This utility is to a large extent compatible with yacc, and in fact is named for it. All input files should use the suffix .y; output files will use the original prefix.

URL: http://www.gnu.org/software/bison.

Options


-b prefix, --file-prefix=prefix

Use prefix for all output files.


-d file, --defines=file

Generate file (usually with a .h suffix), producing #define statements that relate bison's token codes to the token names declared by the user.


-h, --help

Print a help message and exit.


-k, --token-table

Include token names and values of YYNTOKENS, YYNNTS, YYNRULES, and YYNSTATES in file.c.


-l, --no-lines

Exclude #line constructs from code produced in file.c. (Use after debugging is complete.)


-n, --no-parser

Suppress parser code in output, allowing only declarations. Assemble all translations into a switch statement body and print it to file.act.


-o file, --output-file=file

Output to file.


-p prefix, --name-prefix=prefix

Substitute prefix for yy in all external symbols.


-r, --raw

Use bison token numbers, not yacc-compatible translations, in file.h.


-t, --debug

Compile runtime debugging code.


-v, --verbose

Verbose mode. Print diagnostics and notes about parsing tables to file.output.


-V, --version

Display version number.


-y, --yacc, --fixed-output-files

Duplicate yacc's conventions for naming output files.

bzip2

     bzip2 [options] filenames bunzip2 [options] filenames bzcat [option] filenames bzip2recover filenames

File compression and decompression utility similar to gzip, but uses a different algorithm and encoding method to get better compression. bzip2 replaces each file in filenames with a compressed version of the file and with a .bz2 extension appended. bunzip2 decompresses each file compressed by bzip2 (ignoring other files, except to print a warning). bzcat decompresses all specified files to standard output, and bzip2recover is used to try to recover data from damaged files.

Additional related commands include bzcmp, which compares the contents of bzipped files; bzdiff, which creates diff (difference) files from a pair of bzip files; bzgrep, to search them; and the bzless and bzmore commands, which apply the more and less commands to bunzip2 output as bzcat does with the cat command. See cat, cmp, diff, grep, less, and more for information on how to use those commands.

URL: http://www.bzip.org.

Options


--

End of options; treat all subsequent arguments as filenames.


- dig

Set block size to dig x 100KB when compressing, where dig is a single digit from 1 to 9.


--best

Same as -9.


-c, --stdout

Compress or decompress to standard output.


-d, --decompress

Force decompression.


--fast

Same as -1.


-f, --force

Force overwrite of output files. Default is not to overwrite. Also forces breaking of hard links to files.


-k, --keep

Keep input files; don't delete them.


-L, --license, -V, --version

Print license and version information and exit.


-q, --quiet

Print only critical messages.


-s, --small

Use less memory, at the expense of speed.


-t, --test

Check the integrity of the files, but don't actually decompress them.


-v, --verbose

Verbose mode. Show the compression ratio for each file processed. Add more -v's to increase the verbosity.


-z, --compress

Force compression, even if invoked as bunzip2 or bzcat.

cal

     cal [options] [[month] year]

With no arguments, print a calendar for the current month. Otherwise, print either a 12-month calendar (beginning with January) for the given year or a one-month calendar of the given month and year. month ranges from 1 to 12; year ranges from 1 to 9999.

GNU/Linux and Mac OS X Options


-j

Display Julian dates (days numbered 1 to 365, starting from January 1).


-y

Display entire year.

GNU/Linux Options


-1

Print a one-month calendar. This is the default.


-3

Print a three-month calendar: previous month, current month, and next month.


-m

Display Monday as the first day of the week.


-s

Display Sunday as the first day of the week. This is the default.

Examples

cal 12 2007     cal 2007 > year_file

calendar

     calendar [options]

Read your calendar file and display all lines that contain the current date. The calendar file is like a memo board. You create the file and add entries like the following:

     5/4     meeting with design group at 2 pm     may 6   pick up anniversary card on way home

When you run calendar on May 4, the first line is displayed. calendar can be automated by using crontab or at, or by including it in your startup files, .profile or .login.

Solaris Option


-

Allow a privileged user to invoke calendar for all users, searching each user's login directory for a file named calendar. Entries that match are sent to a user via mail. This feature is intended for use via cron. It is not recommended in networked environments with large user bases.

Mac OS X Options

The Mac OS X version of calendar has a number of additional features not described here. See calendar(1) for more details.


-a

Same as the Solaris - option, above.


-A count

Print lines matching today's date, and for the next count days forward.


-B count

Print lines matching today's date, and for the previous count days backward.


-d MMDD[[ YY]YY]

Print entries for the given date. The year may be specified using either two or four digits.


-f file

Use file instead of $HOME/calendar.


-F daynum

Day number daynum is the "Friday," i.e., the day before the weekend starts. The default is 5.


-l count

Look ahead count days and display the entries for that date also.


-t dd[ .mm[ .yyyy]]

For testing, set the date to the given value.


-w ndays

Add ndays to the number of "lookahead" days if and only if the originally provided day is a Friday. The default value is 2, which causes calendars for Fridays to also print entries for the following weekend.


-W count

Like -A, but do not include weekends in the count of days to look ahead.

cancel

     cancel [options] [printer]

Cancel print requests made with lp. The request can be specified by its ID, by the printer on which it is currently printing, or by the username associated with the request (only privileged users can cancel another user's print requests). Use lpstat to determine either the id or the printer to cancel.

Common Options


id

Cancel print request id.


-u user

Cancel request associated with user.

GNU/Linux and Mac OS X Options

GNU/Linux and Mac OS X use CUPS, the Common Unix Printing System. See http://www.cups.org for more information. Besides the above options, the CUPS cancel command accepts the following:


-a

Remove all jobs from the given destination.


-h host

Treat host as the name of the print server. The default is localhost or the value of the CUPS_SERVER environment variable.

cat

     cat [options] [files  ]

Read one or more files and print them on standard output. Read standard input if no files are specified or if - is specified as one of the files; end input with EOF. Use the > shell operator to combine several files into a new file; >> appends files to an existing file.

Solaris and Mac OS X Options


-b

Like -n, but don't number blank lines.


-e

Print a $ to mark the end of each line. Must be used with -v.


-n

Number lines.


-s

Suppress messages about nonexistent files. (Note: on some systems, -s squeezes out extra blank lines.)


-t

Print each tab as ^I and each form feed as ^L. Must be used with -v.


-u

Print output as unbuffered (default is buffered in blocks or screen lines).


-v

Display control characters and other nonprinting characters.

GNU/Linux Options


-A, --show-all

Same as -vET.


-b, --number-nonblank

Number all nonblank output lines, starting with 1.


-e

Same as -vE.


-E, --show-ends

Print $ at the end of each line.


-n, --number

Number all output lines, starting with 1.


-s, --squeeze-blank

Squeeze down multiple blank lines to one blank line.


-t

Same as -vT.


-T, --show-tabs

Print TAB characters as ^I.


-u

Ignored; retained for Unix compatibility.


-v, --show-nonprinting

Display control and nonprinting characters, with the exception of LINEFEED and TAB.

Examples

cat ch1                   Display a file     cat ch1 ch2 ch3 > all     Combine files     cat note5 >> notes        Append to a file     cat > temp1               Create file at terminal; end with EOF     cat > temp2 << STOP       Create file at terminal; end with STOP

cc

     cc [options] files

Compile one or more C source files (.c), assembler source files (.s), or preprocessed C source files (.i). cc automatically invokes the loader ld (unless -c is supplied). In some cases, cc generates an object file having a .o suffix and a corresponding root name. By default, output is placed in a.out. cc accepts additional system-specific options.

General Notes

  • On GNU/Linux and Mac OS X, cc is just a frontend for GCC, the GNU Compiler Collection.

  • Options for cc vary wildly across Unix systems. We have chosen here to document only those options that are commonly available. You will need to check your local documentation for complete information.

  • Usually, cc passes any unrecognized options to the loader, ld.

Solaris Notes

  • Solaris does not come with Sun's C compiler. If you purchase Sun's compiler, it will be installed in /opt/SUNWspro/bin. You should add that directory to your PATH. Solaris does make GCC available in /usr/sfw/bin, so if you installed the optional software, you may choose to use GCC instead.

  • The other tools that the C and C++ compilers need (the assembler and loader) are found in /usr/ccs/bin. You should add that directory to your PATH also.

Options


-c

Suppress loading and keep any object files that were produced.


-Dname[= def]

Supply a #define directive, defining name to be def or, if no def is given, the value 1.


-E

Run only the macro preprocessor, sending results to standard output.


-g

Generate more symbol-table information needed for debuggers.


-Idir

Search for include files in directory dir (in addition to standard locations). Supply a -I for each new dir to be searched.


-lname

Link source file with library files libname.so or libname.a.


-Ldir

Like -I, but search dir for library archives.


-o file

Send object output to file instead of to a.out.


-O

Optimize object code (produced from .c or .i files). Some compilers accept an additional argument to -O specifying the optimization level.


-p

Generate benchmark code to count the times each routine is called. File mon.out is created, so prof can be used later to produce an execution profile.


-pg

Provide profile information for use with gprof.


-P

Run only the preprocessor and place the result in file.i.


-S

Compile (and optimize, if -O is supplied), but don't assemble or load; assembler output is placed in file.s.


-Uname

Remove definition of name, as if through an #undef directive.

Example

Compile xpop.c and load it with the X libraries:

     cc -o xpop xpop.c -lXaw -lXmu -lXt -lX11

cd

     cd [dir]

Change directory. cd is a built-in shell command. See Chapters 4 and 5.

chgrp

     chgrp [options] newgroup files

Change the group of one or more files to newgroup. newgroup is either a group ID number or a group name located in /etc/group. You must own the file or be a privileged user to succeed with this command.

Common Options


-f, --quiet, --silent

Do not print error messages about files that can't be changed.


-h, --no-dereference

Change the group on symbolic links. Normally, chgrp acts on the file referenced by a symbolic link, not on the link itself.


-R, --recursive

Recursively descend through the directory, including subdirectories and symbolic links, setting the specified group ID as it proceeds. The last of -H, -L, and -P take effect when used with -R.

GNU/Linux and Mac OS X Options


-H

When used with -R, if a command-line argument is a symbolic link to a directory, recursively traverse the directory. In other words, follow the link.


-L

When used with -R, if any symbolic link points to a directory, recursively traverse the directory.


-P

When used with -R, do not follow any symbolic links. This is the default.


-v, --verbose

Verbosely describe ownership changes.

GNU/Linux Options


-c, --changes

Print information about files that are changed.


--dereference

Change the group of the file pointed to by a symbolic link, not the group of the symbolic link itself. This is the default.


--no-preserve-root

Do not treat the root directory, /, specially (the default).


--preserve-root

Do not operate recursively on /, the root directory.


--reference=filename

Change the group to that associated with filename. In this case, newgroup is not specified.

chmod

     chmod [options] mode files

Change the access mode of one or more files. Only the owner of a file or a privileged user may change its mode. Create mode by concatenating the characters from who, opcode, and permission. who is optional (if omitted, default is a); choose only one opcode.

Common Options


-f, --quiet, --silent

Do not print error messages about files that cannot be changed.


-R, --recursive

Recursively descend through the directory, including subdirectories and symbolic links, setting the specified group ID as it proceeds. The last of -H, -L, and -P takes effect when used with -R.

GNU/Linux and Mac OS X Option


-v, --verbose

Verbosely describe ownership changes.

GNU/Linux Options


-c, --changes

Print information about files that are changed.


--no-preserve-root

Do not treat the root directory, /, specially (the default).


--preserve-root

Do not operate recursively on /, the root directory.


--reference=filename

Change the group to that associated with filename. In this case, newgroup is not specified.

Mac OS X Options


+a, +a#, -a, =a#

Parse, order, remove or rewrite ACL entries. See the chmod(1) manpage for more information.


-C

Exit nonzero if any files have ACLs in noncanonical order.


-E

Read new ACL information from standard input. If it parses correctly, use it to replace the existing ACL information.


-H

When used with -R, if a command-line argument is a symbolic link to a directory, recursively traverse the directory.


-i

Remove the "inherited" bit from all entries in the ACLs of the given files.


-I

Remove all "inherited" entries in the ACLs of the given files.


-L

When used with -R, if any symbolic link points to a directory, recursively traverse the directory.


-P

When used with -R, do not follow any symbolic links. This is the default.

Who

u

User

g

Group

o

Other

a

All (default)


Opcode

+

Add permission

-

Remove permission

=

Assign permission (and remove permission of the unspecified fields)


Permission

r

Read

w

Write

x

Execute

s

Set user (or group) ID

t

Sticky bit; save text mode (file) or prevent removal of files by nonowners (directory)

u

User's present permission

g

Group's present permission

o

Other's present permission

l

Mandatory locking


Alternatively, specify permissions by a three-digit sequence. The first digit designates owner permission; the second, group permission; and the third, others permission. Permissions are calculated by adding the following octal values:

4

Read

2

Write

1

Execute


Note: a fourth digit may precede this sequence. This digit assigns the following modes:

4

Set user ID on execution

2

Set group ID on execution or set mandatory locking

1

Sticky bit


Examples

Add execute-by-user permission to file:

     chmod u+x file

Either of the following assigns read-write-execute permission by owner (7), read-execute permission by group (5), and execute-only permission by others (1) to file

     chmod 751 file     chmod u=rwx,g=rx,o=x file

Any one of the following assigns read-only permission to file for everyone:

     chmod =r file     chmod 444 file     chmod a-wx,a+r file

Set the user ID, assign read-write-execute permission by owner, and assign read-execute permission by group and others:

     chmod 4755 file

chown

     chown [options] newowner[:newgroup] files

Change the ownership of one or more files to newowner. newowner is either a user ID number or a login name located in /etc/passwd. The optional newgroup is either a group ID number (GID) or a group name located in the /etc/group file. When newgroup is supplied, the behavior is to change the ownership of one or more files to newowner and make it belong to newgroup.

Note: some systems accept a period as well as the colon for separating newowner and newgroup. The colon is mandated by POSIX; the period is accepted for compatibility with older BSD systems.

Common Options


-f, --quiet, --silent

Do not print error messages about files that cannot be changed.


-h, --no-dereference

Change the owner on symbolic links. Normally, chown acts on the file referenced by a symbolic link, not on the link itself.


-R, --recursive

Recursively descend through the directory, including subdirectories and symbolic links, setting the specified group ID as it proceeds. The last of -H, -L, and -P takes effect when used with -R.

GNU/Linux and Mac OS X Options


-H

When used with -R, if a command-line argument is a symbolic link to a directory, recursively traverse the directory. In other words, follow the link.


-L

When used with -R, if any symbolic link points to a directory, recursively traverse the directory.


-P

When used with -R, do not follow any symbolic links. This is the default.


-v, --verbose

Verbosely describe ownership changes.

GNU/Linux Options


-c, --changes

Print information about files that are changed.


--dereference

Change the group of the file pointed to by a symbolic link, not the group of the symbolic link itself. This is the default.


--from=old-owner: old-group

Change the owner/group of the file to the new values only if the original values of the owner/group match old-owner and old-group. Either one may be omitted.


--no-preserve-root

Do not treat the root directory, /, specially (the default).


--preserve-root

Do not operate recursively on /, the root directory.


--reference=filename

Change the owner to that associated with filename. In this case, newowner is not specified.

cksum

     cksum [files]

Calculate and print a cyclic redundancy check (CRC) sum for each file. The CRC algorithm is based on the polynomial used for Ethernet packets. For each file, cksum prints a line of the form:

     sum count filename

Here, sum is the CRC, count is the number of bytes in the file, and filename is the file's name. The name is omitted if standard input is used.

Mac OS X Option


-o algorithm

Use a historical algorithm for computing the checksum. Valid values are 1, for the historic BSD 16-bit sum checksum, 2, for the historic System V 32-bit sum checksum, and 3 for a 32-bit CRC that is different from the default algorithm.

clear

     clear [term]

Clear the terminal display. The Solaris version allows an optional terminal name indicating the terminal's type. Normally this value is taken from the TERM environment variable.

cmp

     cmp [options] file1 file2 [skip1 [skip2]]

Compare file1 with file2. Use standard input if file1 or file2 is -. (See also comm and diff.) skip1 and skip2 are optional offsets in the files at which the comparison is to start. The exit codes are as follows:

0

Files are identical.

1

Files are different.

2

Files are inaccessible.


Common Options


-l, --verbose

Print offsets and codes of all differing bytes.


-s, --quiet, --silent

Work silently; print nothing, but return exit codes.

GNU/Linux and Mac OS X Options


-b, --print-bytes

Print differing bytes.


-i num1[: num2], --ignore-initial=num1[: num2]

Ignore the first num1 bytes of input. With num2, skip num1 bytes from the first file and num2 bytes from the second file.


-n max, --bytes=max

Read and compare no more than max bytes.

Example

Print a message if two files are the same (exit code is 0):

     cmp -s old new && echo 'no changes'

comm

     comm [options] file1 file2

Compare lines common to the sorted files file1 and file2. Three-column output is produced: lines unique to file1, lines unique to file2, and lines common to both files. comm is similar to diff in that both commands compare two files. In addition, comm can be used like uniq; that is, comm selects duplicate or unique lines between two sorted files, whereas uniq selects duplicate or unique lines within the same sorted file.

Options


-

Read the standard input.


-1

Suppress printing of Column 1.


-2

Suppress printing of Column 2.


-3

Suppress printing of Column 3.


-12

Print only lines in Column 3 (lines common to file1 and file2).


-13

Print only lines in Column 2 (lines unique to file2).


-23

Print only lines in Column 1 (lines unique to file1).

Example

Compare two lists of top-10 movies and display items that appear in both lists:

     comm -12 shalit_top10 maltin_top10

cp

     cp [options] file1 file2 cp [options] files   directory

Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten). If one of the inputs is a directory, use the -r option.

Common Options


-f, --force

Remove existing files in the destination.


-i, --interactive

Prompt for confirmation (y for yes) before overwriting an existing file.


-p

Preserve the original file's permissions, ownership, and timestamps in the new file.


-r, -R, --recursive

Copy directories recursively. Solaris -R replicates named pipes, instead of reading from them.

GNU/Linux and Mac OS X Options


-H

When used with -R, if a command-line argument is a symbolic link to a directory, recursively traverse the directory.


-L, --dereference

When used with -R, if any symbolic link points to a directory, recursively traverse the directory.


-P

When used with -R, do not follow any symbolic links. This is the default.


-v, --verbose

Before copying , print the name of each file.

Solaris Option


-@

Copy extended attributes (ACLs, etc.) along with normal attributes.

GNU/Linux Options


-a, --archive

Preserve attributes of original files where possible. The same as -dpR.


-b

Back up files that would otherwise be overwritten.


--backup[= backup-method]

Like -b, but accepts an additional specification controlling how the backup copy should be made. Valid arguments are:

none, off

Never make numbered backups.

t, numbered

Always make numbered backups.

nil, existing

Make numbered backups of files that already have them; otherwise, make simple backups.

never, simple

Always make simple backups.



--copy-contents

Copy the contents of special files when doing a recursive copy.


-d

Same as --no-dereference --preserve=links.


-l, --link

Make hard links, not copies, of nondirectories.


--no-dereference

Do not dereference symbolic links; preserve hard link relationships between source and copy.


--no-preserve[= items]

Do not preserve the given items when copying. See --preserve for more information.


--parents

Preserve intermediate directories in source. The last argument must be the name of an existing directory. For example, the command:

cp --parents jphekman/book/ch1 newdir

copies the file jphekman/book/ch1 to the file newdir/jphekman/book/ch1, creating intermediate directories as necessary.


--preserve[= items]

Preserve the given items when copying. Possible items are all, link, mode, mode, ownership, and timestamps. Default is same as -p.


--remove-destination

Remove each destination file before trying to open it.


--reply=how

Control handling of queries about removing existing files. Valid values for how are yes, no, and query.


-s, --symbolic-link

Make symbolic links instead of copying. Source filenames must be absolute.


--sparse=when

Control handling of copying of sparse files. Valid values for when are auto, always, and never.


--strip-trailing-slashes

Remove trailing slashes from source file names.


-S backup-suffix, --suffix=backup-suffix

Set suffix to be appended to backup files. This may also be set with the SIMPLE_BACKUP_SUFFIX environment variable. The default is ~. You need to explicitly include a period if you want one before the suffix (for example, specify .bak, not bak).


--target-directory=dir

Copy all files into the directory dir.


-u, --update

Do not copy a file to an existing destination with the same or newer modification time.


-x, --one-file-system

Ignore subdirectories on other filesystems.


-Z context, --context=context

Set the security context of the file to context. SELinux only.

Mac OS X Options


-n

Do not overwrite an existing file.

Example

Copy two files to their parent directory (keep the same names):

     cp outline memo ..

cpio

     cpio control_options [options]

Copy file archives in from, or out to, tape or disk, or to another location on the local machine. Each of the three control options, -i, -o, or -p accepts different options. (See also pax and tar.)


cpio -i [ options] [ patterns]


cpio --extract [ options][ patterns]

Copy in (extract) files whose names match selected patterns. Each pattern can include filename metacharacters from the Bourne shell. (Patterns should be quoted or escaped so that they are interpreted by cpio, not by the shell.) If no pattern is used, all files are copied in. During extraction, existing files are not overwritten by older versions in the archive (unless -u is specified).


cpio -o [ options]


cpio --create [ options]

Copy out a list of files whose names are given on the standard input.


cpio -p [ options] directory


cpio --create [ options] directory

Copy (pass) files to another directory on the same system. Destination pathnames are interpreted relative to the named directory.

Comparison of Valid Options

Options available to the -i, -o, and -p options are shown respectively in the first, second, and third row below. (The - is omitted for clarity.)

     -i:   6   b B c C d E f   H I k   m M n r R s S t u v V z Z     -o: 0 a A   B c C       F H     L   M O             v V z Z     -p: 0 a           d           l L m   P   R       u v V

Common Options


-a, --reset-access-time

Reset access times of input files.


-A, --append

Append files to an archive (must use with -O or -F).


-b, --swap

Swap bytes and half-words to convert between big-endian and little-endian 32-bit integers. Words are four bytes.


-B

Block input or output using 5120 bytes per record (default is 512 bytes per record).


-c

Read or write header information as ASCII characters; useful when source and destination machines are different types.


-C n, --io-size=n

Like -B, but block size can be any positive integer n.


-d, --make-directories

Create directories as needed.


-E file, --pattern-file=file

Extract filenames listed in file from the archive.


-f, --nonmatching

Reverse the sense of copying; copy all files except those that match patterns.


-H type, --format=type

Read or write header information according to format. Values for format are bar (bar format header and file, read-only, Solaris only), crc (ASCII header containing expanded device numbers), odc (ASCII header containing small device numbers), ustar (IEEE/P1003 Data Interchange Standard header), or tar (tar header). Solaris also allows CRC, TAR, and USTAR.

Mac OS X allows tar and ustar, as well as bcpio for the original binary cpio format, cpio for the original octal character (ASCII) cpio format, and sv4cpio for the System V Release 4 hexadecimal character format.

GNU/Linux allows tar and ustar, as well as bin for the original binary format, crc for the System V Release 4 format with an additional checksum, hpbin for the obsolete binary format used by the HP-UX cpio, hpodc for HP-UX's portable format, newc for the System V Release 4 portable (ASCII) format, and odc for the old POSIX.1 portable (ASCII) format.


-I file

Read file as an input archive. As with -F, GNU/Linux allows file to specify a remote archive.


-l, --link

Link files instead of copying. Can be used only with -p.


-L, --dereference

Follow symbolic links.


-m, --preserve-modification-time

Retain previous file-modification time.


-O file

Direct the output to file. As with -F, GNU/Linux allows file to specify a remote archive.


-r, --rename

Rename files interactively.


-R ID, -owner ID

Reassign file ownership and group information of extracted files to the user whose login ID is ID (privileged users only). GNU/Linux allows ID to be of the form [user][sep group], i.e., a user or group name or ID or both. If both, sep may be a colon or period. Use a leading separator for just a group. For example: arnold:users, arnold, or :users.


-s, --swap-bytes

Swap bytes of each two-byte half-word.


-S, --swap-half-words

Swap half-words of each four-byte word.


--sparse

For -o and -p, write files that have large blocks of zeros as sparse files.


-t, --list

Print a table of contents of the input (create no files). When used with the -v option, resembles output of ls -l.


-u, --unconditional

Unconditional copy; old files can overwrite new ones.


-v, --verbose

Print a list of filenames processed.


-V, --dot

Print a dot for each file read or written (this shows cpio at work without cluttering the screen).

Solaris and GNU/Linux Option


-M msg, --message=msg

Print msg when switching media. Use variable %d in the message as a numeric ID for the next medium. -M is valid only with -I or -O.

Solaris and Mac OS X Option


-6

Process a PWB Unix Sixth Edition archive format file. Useful only with the -i option, mutually exclusive with -c and -H. Solaris and Mac OS X only.

GNU/Linux and Mac OS X Option


-F file, --file=file

Same as -O. The GNU/Linux version allows file to be of the form user@host:file for accessing a remote archive. The user@ part is optional.

Solaris Options


-k

Skip corrupted file headers and I/O errors.


-P

Preserve ACLs. Can be used only with -p.


-@

With -o, include extended attributes in the archive. These attributes are stored as special files in the archive. These attributes may be restored upon extraction by using -@ with -i.

GNU/Linux Options


--blocksize=size

Set input or output blocksize to size x 512 bytes.


--force-local

Assume that file (provided by -F, -I, or -O) is a local file, even if it contains a colon (:) indicating a remote file.


-n, --numeric-uid-gid

When verbosely listing contents, show user ID and group ID numerically.


--no-absolute-filenames

Create all copied-in files relative to the current directory.


--no-preserve-owner

Make all copied files owned by yourself, instead of the owner of the original. Can be used only if you are a privileged user.


--only-verify-crc

For a CRC-format archive, verify the CRC of each file; don't actually copy the files in.


--quiet

Don't print the number of blocks copied.


--rsh-command=command

Tell mt to use command for accessing remote archives instead of rsh or ssh.


-0, --null

(Digit zero.) With -o or -p, read a list of filenames terminated with a NUL byte (all zeros) instead of a newline. This allows archiving files whose names contain newlines. GNU find can produce such a list of names.

Mac OS X Options


-z

Compress the archive using gzip.


-Z

Compress the archive using the old compress command.

Examples

Generate a list of old files using find; use list as input to cpio:

     find . -name "*.old" -print | cpio -ocBv > /dev/rmt/0

Restore from a tape drive all files whose name contains save (subdirectories are created if needed):

     cpio -icdv "*save*" < /dev/rmt/0

To move a directory tree:

     find . -depth -print | cpio -padml /mydir

crontab

     crontab [file]     crontab options [user]

View, install, or uninstall your current crontab file. On Mac OS X and GNU/Linux, a privileged user can run crontab for another user by supplying -u user. On Solaris, supply user following one of -e, -l, or -r.

A crontab file is a list of commands, one per line, that executes automatically at a given time. Numbers are supplied before each command to specify the execution time. The numbers appear in five fields, as follows:

     Minute            0-59     Hour               0-23     Day of month          1-31     Month            1-12     Day of week           0-6, with 0 = Sunday

Use a comma between multiple values, a hyphen to indicate a range, and an asterisk to indicate all possible values. For example, assuming the crontab entries below:

     59 3 * * 5          find / -print | backup_program     0 0 1,15 * *        echo "Timesheets due" | mail user

The first command backs up the system files every Friday at 3:59 a.m., and the second command mails a reminder on the 1st and 15th of each month.

Common Options


-e

Edit the user's current crontab file (or create one).


-l

List the user's file in the crontab directory.


-r

Delete the user's file in the crontab directory.

GNU/Linux and Mac OS X Option


-u user

Indicate which user's crontab file will be acted upon.

csh

     csh [options] [file] [arguments]

Command interpreter that uses syntax resembling C. csh (the C shell) executes commands from a terminal or a file. On Mac OS X and most GNU/Linux systems, /bin/csh is a link to tcsh, an enhanced version of the shell. Solaris supplies tcsh as a separate program. See also tcsh. See Chapter 5 for information on tcsh, including command-line options.

csplit

     csplit [options] file arguments

Separate file into sections and place sections in files named xx00 through xxn (n < 100), breaking file at each pattern specified in arguments. A filename of - reads from standard input. See also split.

Common Options


-f prefix, --prefix=prefix

Name new files prefix 00 tHRough prefixN (default is xx00 tHRough xxn).


-k, --keep-files

Keep newly created files, even when an error occurs (which would normally remove these files). This is useful when you need to specify an arbitrarily large repeat argument, {n}, and you don't want the "out of range" error to remove the new files.


-n num, --digits=num

Use output filenames with numbers num digits long. The default is 2.


-s, --quiet, --silent

Suppress all character counts.

GNU/Lnux Options


-b suffix, --suffix-format=suffix

Append suffix to output filename. This option causes -n to be ignored. suffix must specify how to convert the binary integer to readable form by including one of the following: %d, %i, %u, %o, %x, or %X. The value of suffix determines the format for numbers as follows:

%d, %i

Signed decimal.

%u

Unsigned decimal.

%o

Octal.

%x, %X

Hexadecimal.



-q

Same as -s.


-z, --elide-empty-files

Do not create empty output files. However, number as if those files had been created.

Arguments

Any one or a combination of the following expressions. Arguments containing blanks or other special characters should be surrounded by single quotes.


/ expr/

Create file from the current line up to the line containing the regular expression expr. This argument takes an optional suffix of the form +n or -n, where n is the number of lines below or above expr.


% expr%

Same as /expr/, except that no file is created for lines previous to the line containing expr.


num

Create file from current line up to line number num.


{ n}

Repeat argument n times. May follow any of the above arguments. Files will split at instances of expr or in blocks of num lines. On GNU/Linux, if * is given instead of n, repeat argument until input is exhausted.

Examples

Create up to 20 chapter files from the file novel:

     csplit -k -f chap. novel '%CHAPTER%' '{20}'

Create up to 100 address files (xx00 through xx99), each four lines long, from a database named address_list:

     csplit -k address_list 4 {99}

ctags

     ctags [options] files

Create a list of function and macro names that are defined in the specified C, Pascal, FORTRAN, yacc, or lex source files. Solaris ctags can also process C++ source files. The output list (named tags by default) contains lines of the form:

     name        file        context

where name is the function or macro name, file is the source file in which name is defined, and context is a search pattern that shows the line of code containing name. After the list of tags is created, you can invoke vi on any file and type:

     :set tags=tagsfile     :tag name

This switches the vi editor to the source file associated with the name listed in tagsfile (which you specify with -f).

GNU/Linux systems often ship with the Exuberant ctags (see http://ctags.sourceforge.net). That version also understands C++, Java, Perl, Python, flex, and bison. The Exuberant ctags accepts many more options not listed here, see ctags(1) for more information. Of particular note is the -e option, which creates tag files usable with Emacs.

Options


-a

Append tag output to existing list of tags.


-B

context uses backward search patterns.


-d

Create tags for #define macros that don't take arguments (symbolic constants). Mac OS X only.


-ftagsfile

Place output in tagsfile (default is tags).


-F

context uses forward search patterns (default).


-t

Include C typedefs as tags.


-u

Update tags file to reflect new locations of functions (e.g., when functions are moved to a different source file). Old tags are deleted; new tags are appended.


-v

Produce a listing (index) of each function, source file, and page number (1 page = 64 lines). -v is intended to create a file for use with vgrind (a troff preprocessor for pretty-printing source code).


-w

Suppress warning messages.


-x

Produce a listing of each function, its line number, source file, and context.

Examples

Store tags in Taglist for all C programs:

     ctags -f Taglist *.c

Update tags and store in Newlist:

     ctags -u -f Newlist *.c

curl

     curl [options] [URL ...]

curl retrieves files from the Internet, most often using FTP or HTTP. It has a plethora of options, making it difficult to use easily. One of curl's main strengths is that it may be used to automate file uploading. See also wget.

URLs: http://curl.haxx.se and ftp://ftp.sunet.se/pub/www/utilities/curl/.

Primary Options

For many of the options, using them multiple times toggles the behavior, turning a particular mode off if it was on or vice versa.


--connect-timeout seconds

Limit the connection phase to seconds seconds.


-C offset, --continue-at offset

Continue a previous file transfer at offset bytes. May be used with both downloads and uploads. Use -C - to have curl automatically determine the offset.


--create-dirs

When used with -o, create local directories as needed.


--disable-epsv

Do not use the EPSV FTP command for passive FTP transfers. Normally, curl tries the EPSV command before the PASV command.


-f, --fail

Fail silently upon HTTP server errors. Mainly useful for scripts.


--ftp-pasv

Use the FTP PASV command. This is the default.


-h, --help

Print a (relatively) brief help message.


-K configfile, --config configfile

Use configfile as the configuration file, instead of the default $HOME/.curlrc. Use - to read configuration information from standard input.


--limit-rate speed

Limit transfers to speed. The default units is bytes per second, but you may use a trailing k or K for kilobytes, m or M for megabytes, or g or G for gigabytes. The -Y option overrides this option.


--max-filesize bytes

If curl can tell that a file exceeds bytes size, it will not download the file. Otherwise, this option has no effect.


-m seconds, --max-time seconds

Do not exceed seconds for the entire operation. This prevents batch jobs from hanging due to slow networks or dead links.


-M, --manual

Display the full help text (over 2400 lines!), in the form of a manpage.


-o file, --output file

Write the output to file instead of to standard output. See the manpage for more details. See also --create-dirs.


-q

When used as the first parameter, do not read $HOME/.curlrc.


-s, --silent

Silent mode; do not print a progress meter or any error messages.


-S, --show-error

With -s, do display error messages.


-T file, --upload-file file

Upload file to the URL named on the command line. Use - to read standard input. The URL must end with a / if it's a directory, in which case curl will use file as the name of the file to create in the remote directory.


-u user: password, --user user: password

Supply user and password to the server for authentication.


-U user: password, --proxy-user user: password

Supply user and password for proxy authentication.


--url URL

Retrieve URL. This option is mainly for use in a configuration file.


-v, --verbose

Be verbose during file retrieval. Mainly for debugging.


-V, --version

Print version and supported-feature information.


-x proxyhost[: port], --proxy proxyhost[: port]

Use the given host and optional port as the HTTP proxy. The default port is 1080.


-#, --progress-bar

Print progress information as a progress bar instead of as statistics.

See the manpage for a description of the other options.

cut

     cut options [files]

Select a list of columns or fields from one or more files. Either -c or -f must be specified. list is a sequence of integers. Use a comma between separate values and a hyphen to specify a range (e.g., 1-10,15,20 or 50-). See also paste and join.

Common Options


-b list, --bytes list

This list specifies byte positions, not character positions. This is important when multibyte characters are used. With this option, lines should be 1023 bytes or less in size.


-c list, --characters list

Cut the character positions identified in list.


-d c, --delimiter c

Use with -f to specify field delimiter as character c (default is tab); special characters (e.g., a space) must be quoted.


-f list, --fields list

Cut the fields identified in list.


-n

Do not split characters. When used with -b, cut doesn't split multibyte characters.


-s, --only-delimited

Use with -f to suppress lines without delimiters.

GNU/Linux Option


--output-delimiter=string

Use string as the output delimiter. By default, the output delimiter is the same as the input delimiter.

Examples

Extract usernames and real names from /etc/passwd:

     cut -d: -f1,5 /etc/passwd

Find out who is logged on, but list only login names:

     who | cut -d" " -f1

Cut characters in the fourth column of file, and paste them back as the first column in the same file. Send the results to standard output:

     cut -c4 file | paste - file

date

     date [option] [+format]     date [options] [string]

In the first form, print the current date and time, specifying an optional display format. In the second form, a privileged user can set the current date by supplying a numeric string. format can consist of literal text strings (blanks must be quoted) as well as field descriptors, whose values will appear as described below (the listing shows some logical groupings).

Format

%n

Insert a newline.

%t

Insert a tab.

  

%m

Month of year (01-12).

%d

Day of month (01-31).

%y

Last two digits of year (00-99).

%D

Date in %m/%d/%y format.

  

%b

Abbreviated month name.

%e

Day of month (1-31); pad single digits with a space.

%Y

Four-digit year (e.g., 1996).

%g

Week-based year within century (00-99).

%G

Week-based year, including the century (0000-9999).

  

%h

Same as %b.

%B

Full month name.

  

%H

Hour in 24-hour format (00-23).

%M

Minute (00-59).

%S

Second (00-61); 61 permits leap seconds and double leap seconds.

%R

Time in %H:%M format.

%T

Time in %H:%M:%S format.

%k

Hour (24-hour clock, 0-23); single digits are preceded by a space.

%l

Hour (12-hour clock, 1-12); single digits are preceded by a space.

  

%I

Hour in 12-hour format (01-12).

%p

String to indicate a.m. or p.m. (default is AM or PM).

%r

Time in %I:%M:%S %p format.

  

%a

Abbreviated weekday.

%A

Full weekday.

%w

Day of week (Sunday = 0).

%u

Weekday as a decimal number (1-7), Sunday = 1.

%U

Week number in year (00-53); start week on Sunday.

%W

Week number in year (00-53); start week on Monday.

%V

The ISO-8601 week number (01-53). In ISO-8601, weeks begin on a Monday, and week 1 of the year is the one that includes both January 4th and the first Thursday of the year. If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of the last week of the previous year.

%j

Julian day of year (001-366).

%Z

Time-zone name.

  

%x

Country-specific date format.

%X

Country-specific time format.

%c

Country-specific date and time format (default is %a %b %e %T %Z %Y; e.g., Sun Jul 10 06:00:59 EDT 2005).

%F

ISO 8601 date format, equivalent to %Y-%m-%d. Not on Solaris.

  

%N

The number of nanonseconds within the current second. GNU/Linux only.

%s

The date and time as seconds since the Epoch. Not on Solaris.


The actual formatting is done by the strftime (3) library routine. The country-specific formats depend on the setting of the LC_CTYPE, LC_TIME, and LC_MESSAGES (and on Solaris, NLSPATH) environment variables.

Common Option


-u, --utc, --universal

Display or set the time using Greenwich Mean Time (UTC).

Solaris Option


-a s. f

(Privileged user only.) Gradually adjust the system clock until it drifts s seconds away from what it thinks is the "current" time. (This allows continuous micro-adjustment of the clock while the system is running.) f is the fraction of seconds by which time drifts. By default, the clock speeds up; precede s by a -- to slow down.

GNU/Linux Options


-d date, --date date

Display date, which should be in quotes and may be in the format d days or m months d days to print a date in the future. Specify ago to print a date in the past. You may include formatting (see the previous section).


-f datefile, --file=datefile

Like -d, but printed once for each line of datefile.


-I [ timespec], --iso-8601[= timespec]

Display in ISO-8601 format. If specified, timespec can have one of the values date (for date only), hours, minutes, or seconds to get the indicated precision.


-r file, --reference=file

Display the time file was last modified.


-R, --rfc-822

Display the date in RFC 822 format.


-s date, --set date

Set the date to date.

Mac OS X Options


-n

(Privileged user only.) Set the date on the local machine only; do not use timed(8) to set the time on all the machines in the local network.


-r seconds

Display the time represents by seconds seconds since the Epoch.

Strings for Setting the Date

A privileged user can set the date by supplying a numeric string. string consists of time, day, and year concatenated in one of three ways: time or [day ]time or [day ]time [year ]. Note: don't type the brackets.


time

A two-digit hour and two-digit minute (HHMM ); HH uses 24-hour format.


day

A two-digit month and two-digit day of month (mmdd ); default is current day and month.


year

The year specified as either the full four digits or just the last two digits; default is current year.

Examples

Set the date to July 1 (0701), 4 a.m. (0400), 1999 (99):

     date 0701040099

Demonstrate the formatting capabilities:

     $ date +"Hello%t Date is %D %n%t Time is %T"     Hello    Date is 06/26/05              Time is 11:23:21

dc

     dc [file]

An interactive desk calculator program that performs arbitrary-precision integer arithmetic (input may be taken from a file). Normally you don't run dc directly, since it's invoked by bc (see bc). dc provides a variety of one-character commands and operators that perform arithmetic; dc works like a Reverse Polish calculator; therefore, operators and commands follow the numbers they affect. Operators include + - / * % ^ (as in C, although ^ means exponentiation).

GNU/Linux and Mac OS X use the GNU version of dc that accepts a number of options and has additional commands; see dc(1) for the details. Some simple commands follow.

p

Print current result.

q

Quit dc.

c

Clear all values on the stack.

v

Take square root.

i

Change input base; similar to bc's ibase.

o

Change output base; similar to bc's obase.

k

Set scale factor (number of digits after decimal); similar to bc's scale.

!

Remainder of line is a Unix command.


Examples

$ dc      3 2 ^ p          Evaluate 3 squared, then print result     9     8 * p            Current value (9) times 8, then print result     72     47 - p           Subtract 47 from 72, then print result     25     v p              Square root of 25, then print result     5     2 o p            Display current result in base 2     101

Note: spaces are not needed except between numbers.

dd

     dd [option=value]

Make a copy of an input file (if=), or standard input if no named input file, using the specified conditions, and send the results to the output file (or standard output if of is not specified). Any number of options can be supplied, although if and of are the most common and are usually specified first. Because dd can handle arbitrary block sizes, it is useful when converting between raw physical devices.

Although dd provides options for ASCII/EBCDIC conversions, iconv is better suited to that task.


Options


bs= n

Set input and output block size to n bytes; this option supersedes ibs and obs.


cbs= n

Set the size of the conversion buffer (logical record length) to n bytes. Use only if the conversion flag is block or unblock, or one of the ASCII/EBCDIC conversions.


conv= flags

Convert the input according to one or more (comma-separated) flags listed below. The first nine flags are mutually exclusive. The next two are mutually exclusive with each other, as are the following two.

ascii

EBCDIC to ASCII.

asciib

EBCDIC to ASCII, using BSD-compatible conversions. Solaris only.

oldascii

EBCDIC to ASCII, using BSD-compatible conversions. Mac OS X only.

ebcdic

ASCII to EBCDIC.

ebcdicb

ASCII to EBCDIC, using BSD-compatible conversions. Solaris only.

oldebcdic

ASCII to EBCDIC, using BSD-compatible conversions. Mac OS X only.

ibm

ASCII to EBCDIC with IBM conventions.

ibmb

ASCII to EBCDIC with IBM conventions, using BSD-compatible conversions. Solaris only.

oldibm

ASCII to EBCDIC with IBM conventions, using BSD-compatible conversions. Mac OS X only.

  

block

Variable-length records (i.e., those terminated by a newline) to fixed-length records.

unblock

Fixed-length records to variable-length.

  

lcase

Uppercase to lowercase.

ucase

Lowercase to uppercase.

  

noerror

Continue processing when errors occur (up to five in a row).

notrunc

Do not truncate the output file. This preserves blocks in the output file that this invocation of dd did not write. Solaris only.

sparse

When input blocks consist only of zero bytes, try to seek on the output file, creating a sparse file. Mac OS X only.

swab

Swap all pairs of bytes.

sync

Pad input blocks to ibs.



count= n

Copy only n input blocks.


files= n

Copy n input files (e.g., from magnetic tape), then quit.


ibs= n

Set input block size to n bytes (default is 512).


if= file

Read input from file (default is standard input).


obs= n

Set output block size to n bytes (default is 512).


of= file

Write output to file (default is standard output).


iseek= n

Seek n blocks from start of input file (like skip but more efficient for disk file input). Solaris and Mac OS X only.


oseek= n

Same as seek. Solaris and Mac OS X only.


seek= n

Seek n blocks from start of output file.


skip= n

Skip n input blocks; useful with magnetic tape.

You can multiply size values (n) by a factor of 1024, 512, or 2 by appending the letters k, b, or w, respectively. You can use the letter x as a multiplication operator between two numbers.

Examples

Convert an input file to all lowercase:

     dd if=caps_file of=small_file conv=lcase

Retrieve variable-length data; write it as fixed-length to out:

     data_retrieval_cmd | dd of=out conv=sync,block

df

     df [options] [name]

Report the number of free disk blocks and inodes available on all mounted filesystems or on the given name. (On Solaris unmounted filesystems are checked with -F.) name can be a device name (e.g., /dev/dsk/0s9), the directory name of a mount point (e.g., /usr), a directory name, or a remote filesystem name (e.g., an NFS filesystem). Besides the options listed, there are additional options specific to different filesystem types or df modules.

On Solaris and Mac OS X, the default block size is the historic 512 bytes. On GNU/Linux it's 1024 bytes. Furthermore, the output format and option availability both vary wildly among the different systems, as well as between /usr/bin/df and /usr/xpg4/bin/df on Solaris. The end result is that it's hard to use df portably in shell scripts.


Common Options


-a, --all

Provide information about all filesystems, even ones usually marked in /etc/mnttab to be ignored.


-h, --human-readable

Like -k, but in a more "human readable" format, with one line per filesystem.


-i, --inodes

Solaris /usr/ucb/df, Mac OS X, GNU/Linux. Show the number of used and available inodes in a format similar to df -k.


-k, --kilobytes

Print allocation in kilobytes (typically used without other options). This option produces output in the format traditionally used by the BSD version of df.


-l, --local

Report only on local filesystems.


-o suboptions

Supply a comma-separated list of type -specific suboptions.


-P, --portability

Solaris /usr/xpg4/bin/df and Mac OS X: like -k, but use units of 512-byte blocks. On GNU/Linux, this still uses 1024-byte blocks, but the output format conforms to POSIX. (Set POSIXLY_CORRECT in the environment to force GNU df to use 512-byte blocks.)

GNU/Linux and Mac OS X Options


-H, --si

Like -h, but use base 10 for sizes, not base 2.


-m, --megabytes

Use 1048576-byte (1-Mbyte) blocks instead of the default. On Mac OS X, overrides the BLOCKSIZE environment variable.


-t type, --type=type

Show only type filesystems. (Mac OS X in legacy mode.)

Solaris Options


-b

Print only the number of free kilobytes.


-e

Print only the number of free files.


-F type

Report on an unmounted filesystem specified by type. Available types can be seen in the file /etc/vfstab.


-g

Print the whole statvfs structure, overriding other print options.


-n

Print only the filesystem type name; with no other arguments, -n lists the types for all mounted filesystems.


-t

Report total allocated space as well as free space.


-v

/usr/bin/df only. Like -k, but the size unit is the smallest block size supported by each filesystem.


-V

Echo command line but do not execute command.


-Z

Display mounts in all visible zones. The default is to provide information only about filesystems mounted in the local zone.

GNU/Linux Options


-B n, --block-size=n

Show space as n-byte blocks.


--no-sync

Show results without invoking sync first (i.e., without flushing the buffers). This is the default.


--sync

Invoke sync (flush buffers) before getting and showing sizes.


-T, --print-type

Print the type of each filesystem in addition to the sizes.


-x type, --exclude-type=type

Show only filesystems that are not of type type.

Mac OS X Options


-b

Use 512-byte blocks instead of the default. Overrides the BLOCKSIZE environment variable.


-g

Use 1073741824-byte (1-Gigabyte) blocks instead of the default. Overrides the BLOCKSIZE environment variable.


-n

Print out saved information about each filesystem instead of requesting the information anew.


-T type

Prints statistics only for the given filesystem types.

diff

     diff [options] [diroptions] file1 file2

diff reports lines that differ between file1 and file2. Output consists of lines of context from each file, with file1 text flagged by a < symbol and file2 text by a > symbol. Context lines are preceded by the ed command (a, c, or d) that converts file1 to file2. If one of the files is -, standard input is read. If one of the files is a directory, diff locates the filename in that directory corresponding to the other argument (e.g., diff my_dir junk is the same as diff my_dir/junk junk). If both arguments are directories, diff reports lines that differ between all pairs of files having equivalent names (e.g., olddir/program and newdir/program); in addition, diff lists filenames unique to one directory, as well as subdirectories common to both. See also cmp, comm, diff3, dircmp, and sdiff.

GNU/Linux and Mac OS X use GNU diff. See http://www.gnu.org/software/diffutils.

Common Options

Options -c, -C, -D, -e, -f, -h, -n, -u cannot be combined with each other (they are mutually exclusive).


-b, --ignore-space-change

Ignore repeating blanks and end-of-line blanks; treat successive blanks as one.


-c

Produce output in "context diff" format, with three lines of context.


-C n, --context=n

Like -c, but produce n lines of context.


-D symbol, --ifdef=symbol

Merge file1 and file2 into a single file containing conditional C preprocessor directives (#ifdef). Defining symbol and then compiling yields file2; compiling without defining symbol yields file1.


-e, --ed

Produce a script of commands (a, c, d) to re-create file2 from file1 using the ed editor.


-f, --forward-ed

Produce a script to re-create file1 from file2; the script is in the opposite order, so it isn't useful to ed.


-h

Do a half-hearted (but hopefully faster) comparison; complex differences (e.g., long stretches of many changes) may not show up; -e and -f are disabled. GNU diff ignores this option.


-i, --ignore-case

Ignore uppercase and lowercase distinctions.


-n, --rcs

Like -f, but counts changed lines. rcsdiff works this way.


-t, --expand-tabs

Expand tabs in output lines; useful for preserving indentation changed by -c format.


-u

Produce output in "unified diff" format, with three lines of context.


-U n, --unified=n

Like -u, but produce n lines of context.


-w, --ignore-all-space

Like -b, but ignores all spaces and tabs; e.g., a + b is the same as a+b.

Diroptions (Common)

The diroptions are valid only when both file arguments are directories.


-l, --paginate

Long format; output is paginated by pr so that diff listings for each file begin on a new page; other comparisons are listed afterward.


-r, --recursive

Run diff recursively for files in common subdirectories.


-s, --report-identical-files

Report files that are identical.


-S filename, --starting-file=filename

Begin directory comparisons with file, skipping files whose names alphabetically precede file.

Options for GNU diff


-a, --text

Treat all files as text files. Useful for checking to see if binary files are identical.


--binary

Read and write data in binary mode.


-B, --ignore-blank-lines

Ignore blank lines in files.


-d, --minimal

To speed up comparison, ignore segments of numerous changes and output a smaller set of changes.


-E, --ignore-tab-expansion

Ignore differences due to expanding tabs.


--from-file=file

Compare file to each operand. file may be a directory.


-F regexp, --show-function-line=regexp

For context and unified diffs, show the most recent line containing regexp before each block of changed lines.


--horizon-lines=n

In an attempt to find a more compact listing, keep n lines on both sides of the changed lines when performing the comparison.


-H, --speed-large-files

Speed output of large files by scanning for scattered small changes; long stretches with many changes may not show up.


--ignore-file-name-case

Ignore case in filenames during a recursive directory comparison.


-I regexp, --ignore-matching-lines=regexp

Ignore lines in files that match the regular expression regexp.


-L label, --label label, --label=label

For context and unified diffs, print label in place of the filename being compared. The first such option applies to the first filename and the second option to the second filename.


--left-column

For two-column output (-y), show only the left column of common lines.


--no-ignore-file-name-case

Cancel the effect of a previous --ignore-file-name-case option.


-n, --normal

Produce a normal (default style) diff.


-N, --new-file

Treat nonexistent files as empty.


-p, --show-c-function

When handling files in C or C-like languages such as Java, show the function containing each block of changed lines. Assumes -c, but can also be used with a unified diff.


-q, --brief

Output only whether files differ.


--sdiff-merge-assist

Produce sdiff-style output. Used by GNU sdiff when invoking diff.


--strip-trailing-cr

Remove carriage return characters at the end of input lines.


--to-file=file

Compare each operand to file. file may be a directory.


--suppress-common-lines

For two-column output (-y), do not show common lines.


-T, --initial-tab

Insert initial tabs into output to line up tabs properly.


--unidirectional-new-file

When doing directory comparisons, if a file is found only in the second directory, pretend it is present but empty in the first one.


-v, --version

Print version number of diff.


-W n, --width=n

For two-column output (-y), produce columns with a maximum width of n characters. Default is 130.


-x regexp, --exclude=regexp

Do not compare files in a directory whose names match regexp.


-X filename, --exclude-from=filename

Do not compare files in a directory whose names match patterns described in the file filename.


-y, --side-by-side

Produce two-column output.

GNU diff Group Format Options

When merging files, you may wish to have an if-then-else pattern of lines in the result: i.e., one group of lines used in one case, and another group in another case. The options below give you control over the format of such groups.


--changed-group-format=format

Use format for changed lines in if-then-else format.


--new-group-format=format

Use format for lines from the second file in if-then-else format.


--old-group-format=format

Use format for lines from the first file in if-then-else format.


--unchanged-group-format=format

Use format for lines common to both files in if-then-else format.

Within the format strings, special conversion specifiers give you control over the placement of the input text lines in the output.


%<

Lines from the first file, including the final newline. Each line is formatted according to the old line format.


%>

Lines from the second file, including the final newline. Each line is formatted according to the new line format.


%=

Lines common to both files, including the final newline. Each line is formatted according to the unchanged line format.


%%

A literal % character.


%c' C'

A literal character C. Useful for characters special to diff.


%c'\ O'

The character represented by O, which is a string of 1-3 octal digits.


printf-spec line-spec

A printf(3) format specification followed by a letter indicating a number to be printed. Valid specifications are %d, %o, %x, and %X. A field width and precision are allowed, as are the -, 0, and ' flags. The line-spec is one of the letters in the following list. Lowercase letters are used for lines in the first file; uppercase letters represent lines in the second file.

e, E

The number of the line just before the group.

f, F

The number of the first line in the group (same as e + 1).

l, L

The number of the last line of the group.

m, M

The number of the line just after the group (same as l + 1).

n, N

The number of lines in the group (L -F + 1).



%( A= B? T: E)

Conditional substitution. A and B are either numbers or letters as just shown. If they are equal, the result is T, otherwise the result is E. See the Info documentation for GNU diff for more information.

GNU diff Line Format Options

Line format options give you control over the output of individual lines within line groups as specified by the line group options. The options are:


--line-format=format

Apply format to all input lines in if-then-else format.


--new-line-format=format

Apply format to input lines from the second file in if-then-else format.


--old-line-format=format

Apply format to input lines from the first file in if-then-else format.


--unchanged-line-format=format

Apply format to lines common to both files in if-then-else format.

Within the format strings, special conversion specifiers give you control over the placement of the input text lines in the output. The default line format is %l followed by a newline.


%l

The input line's contents, not including the newline.


%L

The input line's contents, including the trailing newline. If the input line did not have a newline, this format preserves that fact.


%%

A literal % character.


%c' C'

A literal character C. Useful for characters special to diff.


%c'\ O'

The character represented by O, which is a string of 1-3 octal digits.


printf-spec line-spec

The same as described earlier in this entry.

diff3

     diff3 [options] file1 file2 file3

Compare three files and report the differences. No more than one of the files may be given as - (indicating that it is to be read from standard input). The output is displayed with the following codes:

= == =

All three files differ.

= == =1

file1 is different.

= == =2

file2 is different.

= == =3

file3 is different.


diff3 is also designed to merge changes in two differing files based on a common ancestor file (i.e., when two people have made their own set of changes to the same file). diff3 can find changes between the ancestor and one of the newer files and generate output that adds those differences to the other new file. Unmerged changes occur where both of the newer files differ from each other and at least one of them differs from the ancestor. Changes from the ancestor that are the same in both of the newer files are called merged changes. If all three files differ in the same place, it is called an overlapping change.

This scheme is used on the command line with the ancestor being file2, the second filename. Comparison is made between file2 and file3, with those differences then applied to file1.

Common Options


-e, --ed

Create an ed script to incorporate into file1 all differences between file2 and file3.


-E, --show-overlap

Same as -e, but mark with angle brackets any lines that differ between all three files.


-x, --overlap-only

Create an ed script to incorporate into file1 all differences between all three files.


-X

Same as -x, but mark with angle brackets any lines that differ between all three files.


-3, --easy-only

Create an ed script to incorporate into file1 differences between file1 and file3.

GNU/Linux and Mac OS X Options


-a, --text

Treat files as text.


-A, --show-all

Create an ed script to incorporate all changes, showing conflicts in bracketed format.


--diff-program=prog

Use prog to compare files instead of diff.


-i

Append the w (save) and q (quit) commands to ed script output.


-L label, --label=label

Use label to replace filename in output.


-m, --merge

Create file with changes merged (not an ed script).


-T, --initial-tab

To line tabs up properly in output, begin lines with a tab instead of two spaces.


-v, --version

Print version information and then exit.

dig

     dig [@server] [options] [name] [type] [class] [query-options]     dig @server name type     dig -h

The dig command queries DNS servers; it is more flexible than the deprecated nslookup command. If you use it without any options or arguments, it searches for the root server. This entry documents the GNU/Linux and Mac OS X version of dig; the Solaris version is slightly different and resides in /usr/sbin. The standard arguments are:


server

The server to query. If no server is supplied, dig checks the name servers listed in /etc/resolv.conf. The address may be an IPv4 dotted address or an IPv6 colon-delimited address. It may also be a hostname, which dig will resolve (through the name servers in /etc/resolv.conf).


name

The domain name to look up.


type

The type of query to perform, such as A, ANY, MX, SIG, and so on. The default is A, but you may use any valid BIND9 query type.

Options


-b address

Set the source IP address for the query.


-c class

Set the class of query. The default value is IN (Internet), but you can choose HS for Hesiod or CH for CHAOSNET.


-f filename

Operate in batch mode, performing the queries in the file you specify.


-h

Print a command-line option summary and exit.


-k filename

Specify a TSIG key file; used for signed transactions. You can also use the -y key, although this is less secure.


-p portnumber

Choose the port number for the query. The default value is the standard DNS port, 53.


-t type

Set the type of query, as with the query argument. The default value is A, but you may use any valid BIND9 query.


-x addr

Perform a reverse lookup, specifying an IPv4 or IPv6 address. You don't need the name, class, or type arguments if you use -x.


-y keyname: keyvalue

Enter the actual key name and value when conducting a signed transaction. Because the key and value can be seen in the output of ps, this is not recommended for use on multiuser systems; use -k instead.

Query Options

There are a large number of query options for dig. Each query option is preceded by +, and many have an opposite version beginning with no. For example, the tcp flag is passed as +tcp, and negated with +notcp. Because there are so many options, only a few are discussed here. For greater detail, see the dig(1) manpage.


+tcp, +notcp

Use (or do not use) the TCP protocol instead of the default UDP.


+domain= searchdomain

Perform a search in the domain specified; this is equivalent to using the +search option and having searchdomain as the sole entry in the search list or domain directive of /etc/resolv.conf.


+search, +nosearch

Use (or don't use) the search list provided in /etc/resolv.conf. The default is not to use the search list.


+time= T

Timeout for queries, in seconds. The default is five, and the minimum is one.


+tries= N

The number of times to retry UDP queries. The default is three, and the minimum is one.

dirname

     dirname pathname

Print pathname, excluding last level. Useful for stripping the actual filename from a pathname. See also basename.

dos2unix

     dos2unix [options] dosfile unixfile

Solaris and GNU/Linux only. Convert files using the DOS extended character set to their ISO standard counterparts. If dosfile and unixfile are the same, the file is overwritten after the conversion is done. See also unix2dos.

Solaris Options


-ascii

Remove extra carriage returns and convert (remove) DOS end-of-file characters for use under Unix.


-iso

Same as the default action.


-7

Convert 8-bit DOS graphics characters to space characters.

GNU/Linux Options


-c mode, --convmode mode

Set the conversion mode to mode. Possible values are ASCII, 7bit, ISO, and Mac. The default is ASCII. This emulates the Solaris version of dos2unix.


-h, --help

Print a command-line summary and exit.


-k, --keepdate

Make the modification date of the output file be the same as that of the input file.


-n infile outfile ..., --newfile infile outfile ...

New file mode. Filenames must be provided in pairs: the first one is the input file, the second is the output file.


-o file ..., --oldfile file ...

Old file mode. Each input file in converted in place. This is the default.


-q, --quiet

Do not print any warnings or messages.


-V, --version

Print version information and exit.

du

     du [options] [directories]

Print disk usage, i.e., the number of blocks used by each named directory and its subdirectories (default is current directory).

On Solaris and Mac OS X, the default block size is the historic 512 bytes. On GNU/Linux it's 1024 bytes. Furthermore, the option availability and meanings vary wildly among the different systems, as well as between /usr/bin/du and /usr/xpg4/bin/du on Solaris. The end result is that it's hard to use du portably in shell scripts, although du -k seems to be a universal least common denominator.


Common Options


-a, --all

Print usage for all files, not just subdirectories.


-h, --human-readable

Print sizes in human-readable format.


-k, --kilobytes

Print information in units of kilobytes.


-L, --dereference

For symbolic links, process the file or directory to which the link refers, not the link itself.


-s, --summarize

Print only the grand total for each named directory.


-x, --one-file-system

Restrict file size evaluations to files on the same filesystem as the command-line file parameter. Not available for Solaris /usr/bin/du.

Solaris Options


-d

Do not cross filesystem boundaries. /usr/bin/du only.


-H

When a symbolic link named on the command line refers to a directory, process the linked-to directory instead of the link itself.


-o

Do not add child-directory statistics to the parent directory's total. No effect if -s is also used. /usr/bin/du only.


-r

Print a "cannot open" message if a file or directory is inaccessible.

GNU/Linux Options


--apparent-size

Print the apparent size, not actual disk usage. This may be larger than actual disk usage due to holes in sparse files, as well as other factors.


-b, --bytes

Print sizes in bytes.


-B, --block-size=size

Use a block size of size bytes.


-c, --total

In addition to normal output, print grand total of all arguments.


-D, --dereference-args

Follow symbolic links, but only if they are command-line arguments.


--exclude=pattern

Exclude files that match pattern.


-H

Like --si, but also evokes a warning. For standards-compliance, this option will eventually become the same as -D.


-l, --count-links

Count the size of all files, whether or not they have already appeared (i.e., via a hard link).


-P, --no-dereference

Do not follow any symbolic links. This is the default.


--max-depth=num

Report sizes for directories only down to num levels below the starting point (which is level 0).


-m, --megabytes

Print sizes in megabytes.


--si

Like -h, but show as power of 1000 rather than 1024.


-S, --separate-dirs

Do not include the sizes of subdirectories when totaling the size of parent directories.


-X, --exclude-from=file

Exclude files that match any pattern in file.


-0, --null

End each output line with a binary zero (NUL) character, instead of a newline.

Mac OS X Options


-c

Print a grand total.


-d depth

Descend only depth directories deep.


-H

When a symbolic link named on the command line refers to a directory, process the linked-to directory instead of the link itself.


-I mask

Ignore files and directories that match mask.


-P

Do not follow any symbolic links. This is the default.


-r

Print a "cannot open" message if a file or directory is inaccessible.

echo

     echo [option] [string]

Echo arguments to standard output . Often used for producing prompts from shell scripts. This is the echo command in the filesystem, not the one built into the shells (see Chapters 4 and 5).

Although echo is conceptually the simplest of all Unix commands, using it in practice is complicated, because of portability and version differences. (Consider using printf instead.) The following sections summarize the differences.

Options


-e

Always interpret escape sequences in argument strings.


-E

Never interpret escape sequences in argument strings.


-n

Do not print the final terminating newline.

Version Differences


Solaris/usr/bin/echo

Does not accept any options. Interprets the escape sequences described next.


Solaris/usr/ucb/echo

Accepts the -n option if it's first. Does not interpret escape sequences.


Mac OS X/bin/echo

Accepts the -n option if it's first, and interprets only the \c escape sequence.


GNU/Linux/bin/echo

Accepts the -e, -E, and -n options, and the options --help and --version.


Bourne shellecho

Does not accept the -n option. Interprets the escape sequences described next, except \a.


C shellecho

Accepts the -n option if it's first. Does not interpret escape sequences. In tcsh, the echo_style shell variable controls emulation of BSD and/or System V echo options and escape sequences.


Korn shellecho

Searches $PATH and behaves like the first version of echo that it finds.


Bashecho

Accepts the -e, -E, and -n options.

Escape Sequences

\a

Alert (ASCII BEL). (Not in /bin/sh's echo.)

\b

Backspace.

\c

Suppress the terminating newline (same as -n).

\E

The ASCII ESCAPE character. Bash built-in echo only.

\f

Formfeed.

\n

Newline.

\r

Carriage return.

\t

Tab character.

\v

Vertical-tab character.

\\

Backslash.

\0nnn

ASCII character represented by octal number nnn, where nnn is 1, 2, or 3 digits and is preceded by a 0.


Examples

echo "testing printer" | lp     echo "TITLE\nTITLE" > file ; cat doc1 doc2 >> file     echo "Warning: ringing bell \07"

ed

     ed [options] [file]

ed is the standard text editor. If the named file does not exist, ed creates it; otherwise, the existing file is opened for editing. As a line editor, ed is generally no longer used because vi and ex have superseded it. However, it can be useful from a slow dial-in connection or over an intercontinental ssh session when using a screen editor is painful. Some utilities, such as diff, continue to make use of ed command syntax.

URL: http://www.gnu.org/fun/jokes/ed.msg.html.

Common Options


-p string

Set string as the prompt for commands (default is *). The P command turns the prompt display on and off.


-s

Suppress character counts, diagnostics, and the ! prompt for shell commands. Earlier versions of ed used plain -; this is still accepted.

System Specific Options


-C

Same as -x, but assume file began in encrypted form. Solaris only.


-G

Forces backwards compatibility. This affects the commands G, V, f, l, m, t, and !!. GNU/Linux only.


-x

Supply a key to encrypt or decrypt file using crypt. Solaris and Mac OS X only.

egrep

     egrep [options] [regexp] [files]

Search one or more files for lines that match a regular expression regexp. egrep doesn't support the metacharacters \(, \), \n, \<, \>, but does support the other metacharacters, as well as the extended set +, ?, |, and ( ). Remember to enclose these characters in quotes. Regular expressions are described in Chapter 6. Exit status is 0 if any lines match, 1 if not, and 2 for errors. See also grep and fgrep.

Solaris /usr/bin/egrep does not support \{, or \}. Mac OS X and GNU/Linux use GNU egrep.

Common Options


-c, --count

Print only a count of matched lines.


-e regexp, --regexp=regexp

Use this if regexp begins with -.


-f file, --file=file

Take expression from file. Multiple expressions may be provided, one per line, in which case any of them may match.


-i, --ignore-case

Ignore uppercase and lowercase distinctions.


-h, --no-filename

Do not print the names of matching files, just the matched lines.


-l, --files-with-matches

List filenames but not matched lines.


-n, --line-number

Print lines and their line numbers.


-s, --no-messages

Silent mode: print only error messages, and return the exit status.


-v --invert-match

Print all lines that don't match regexp.


-x, --line-regexp

Select only those matches that exactly match the whole line. (Only /usr/xpg4/bin/egrep on Solaris, not /usr/bin/egrep.)

GNU grep, egrep, and fgrep Options


-a, --text

Treat a binary file as text. Same as --binary-files=text.


-A count, --after-context=count

Print count lines of trailing context. This places a -- between contiguous groups of matches.


-b, --byte-offset

Before each output line, print the byte offset within the file.


--binary-files=type

egrep examines the first few bytes of a file. If this examination indicates that the file is binary, this option tells egrep what to do. Values for type are: binary, which gives the default behavior of printing a message that the file does (or does not) match; without-match to indicate that the file does not match, or text, which causes egrep to attempt to print the matching line.


-B count, --before-context=count

Print count lines of leading context. This places a -- between contiguous groups of matches.


--color[= when], --colour[= when]

Highlight matching text with color as provided by the GREP_COLOR environment variable. when may be always, auto, or never.


-C count, --context=count

Print count lines of output context. This places a -- between contiguous groups of matches.


-d action, --directories=action

Use action to process directories. Possible values are: read, which means to read the directory as if it was a file; skip, to skip processing the directory; or recurse, to enter it and process its files recursively (equivalent to -r).


-D action, --devices=action

Use action to process device, FIFO, or socket special files. Possible values are: read, which means to read the file; and skip, to skip processing the file.


--exclude=pattern

During recursive directory processing, skip files whose names match pattern.


-E, --extended-regexp

Treat the search pattern as an Extended Regular Expression (ERE). See Chapter 7. This is the default for egrep.


-F, --fixed-strings

Treat the regexp argument as a list of fixed strings, separated by newlines. Any of the strings may match. This is the default for fgrep.


-G, --basic-regexp

Treat the search pattern as an Basic Regular Expression (BRE). See Chapter 7. This is the default for grep.


-H, --with-filename

Always print the name of matching files. (Normally, grep, egrep, and fgrep print the name of the matching file only if more than one filename is listed on the command line.)


--include=pattern

During recursive directory processing, only process files whose names match pattern.


-I

Same as --binary-files=without-match.


-L, --files-without-match

The inverse of -l: print just the names of files that do not match regexp.


-m count, --max-count=count

Stop reading each input file after matching count lines. With -v, stop after count nonmatching lines.


--mmap

Use the mmap(2) system call for reading input, if possible. This can provide a performance improvement.


--label=label

Use label for the name of standard input instead of (standard input).


--line-buffered

Use line buffering. This may decrease performance.


-o, --only-matching

Display only the part of the line that matches regexp.


-P, --perl-regexp

Treat regexp as a Perl regular expression. This option is experimental, don't use it for production shell scripts.


-q, --quiet, --silent

Be quiet; do not produce any output. egrep exits immediately with a zero status if any match is found, even if there were previous errors. See also the -s option.


-r, -R, --recursive

When given a directory, process it recursively, searching the contained files and directories for matches.


-u, --unix-byte-offsets

For MS-DOS and MS-Windows platforms, report byte offsets as if reading a Unix text file. In other words, ignore the carriage return characters. Must be used together with -b.


-U, --binary

For MS-DOS and MS-Windows platforms, force egrep to treat the file as binary data. This prevents the default automatic removal of carriage return characters on that platform.


-V, --version

Print version information to standard output and exit.


-w, --word-regexp

Perform a word match on regexp. The match must be at the beginning of a line or preceded by a non-word-constituent character. The matching text must also be either at the end of the line or be followed by a non-word-constituent character. Word-constituent characters are letters, digits, and the underscore.


-y

An obsolete synonym for -i.


-Z, --null

Use a zero byte (ASCII NUL) instead of the colon that usually follows a filename. Intended for use with -l to produce an unambiguous list of filenames that can be processed by programs like xargs -0 or sort -z. This allows easy processing of filenames that contain unusual characters, such as newlines.

Examples

Search for occurrences of Victor or Victoria in file :

     egrep 'Victor(ia)?' file     egrep '(Victor|Victoria)' file

Find and print strings such as old.doc1 or new.doc2 in files, and include their line numbers:

     egrep -n '(old|new)\.doc?' files

eject

     eject [options] [media]

Solaris and GNU/Linux only. Eject removable media, such as a floppy disk or CD-ROM. On Solaris, necessary for media being managed by vold, or for media without an eject button, such as the floppy drives on some Sun SPARC systems. media is either a device name or a nickname, such as floppy or cdrom.

With volume management available, eject unmounts any filesystems mounted on the named media. In this case, it also displays a pop-up dialog if a window system is running. Without volume management, it simply sends an "eject" command to the given device.

On GNU/Linux, the default device is cdrom. A device name or mount point may be supplied.

Solaris Options


-d

Print the name of the default device to be ejected.


-f

When volume management is not in effect, force the eject, even if the device is busy.


-n

Display the list of nicknames and their corresponding real devices.


-p

Do not use a windowing pop-up dialog.


-q

Query to see if the device has media. Use the exit status to determine the answer.

GNU/Linux Options


-a on|1|off|0, --auto on|1|off|0

Set the auto-eject mode to on or off (equivalent to 1 or 0). If auto-eject mode is on, the device is ejected when closed or unmounted.


-c slotnumber, --changerslot slotnumber

If using a CD-ROM changer, select a CD from one of the slots. Slots are enumerated starting with 0, and the CD-ROM drive must not be playing music or mounted to read data.


-d, --default

List the default device name rather than doing anything.


-f, --floppy

Use floppy commands to eject the drive. Normally, the system will try all methods (CD-ROM, SCSI, floppy, tape) to eject.


-h, --help

Display help information.


-n, --noop

Do not perform any actions; merely display the actions that would be performed.


-p, --proc

Use the mounted files listed in /proc/mounts rather than the ones in /etc/mtab.


-q, --tape

Use tape commands to eject the drive. Normally, the system will try all methods (CD-ROM, SCSI, floppy, tape) to eject.


-r, --cdrom

Use CD-ROM commands to eject the drive. Normally, the system will try all methods (CD-ROM, SCSI, floppy, tape) to eject.


-s, --scsi

Use SCSI commands to eject the drive. Normally, the system will try all methods (CD-ROM, SCSI, floppy, tape) to eject.


-t, --trayclose

Close the CD-ROM drive. Not all drives will respond to this command.


-v, --verbose

Verbose mode: display additional information about actions.


-V, --version

Display version information, then quit.


-x speed, --cdspeed speed

Set the speed multiplier for the CD-ROM to an integer, usually a power of 2. Not all devices support this command. Setting the speed to 0 indicates that the drive should operate at its maximum speed.

emacs

     emacs [options] [files]

A text editor and all-purpose work environment. For more information, see Chapter 8.

env

     env [options] [variable=value ... ] [command]

Display the current environment or, if environment variables are specified, set them to a new value and display the modified environment. If command is specified, execute it under the modified environment.

Options


-, -i, --ignore-environment

Ignore current environment entirely.


-u name, --unset name

Unset the specified variable.

etags

     etags [options] files

Create a list of function and macro names defined in a programming source file. etags generates tags for use by emacs. (ctags produces an equivalent tags file for use with vi.) More than one file may be specified. etags understands many programming languages, including Ada, bison, C++, C, Cobol, Emacs Lisp/Common Lisp, Erlang, flex, Fortran, Java, Perl, Python, Scheme, TeX, and yacc. The output list (named TAGS by default) contains lines of the form:

     name     file     context

where name is the function or macro name, file is the source file in which name is defined, and context is a search pattern that shows the line of code containing name. After the list of tags is created, you can invoke Emacs on any file and type:

     M-x visit-tags-table

You will be prompted for the name of the tag table; the default is TAGS. To switch to the source file associated with the name listed in tagsfile, type:

     M-x find-tag

You will be prompted for the tag you would like Emacs to search for.

This entry documents the etags program shipped with GNU Emacs. A related ctags program is also included for generating a tags file for vi. Some of the options below only work with GNU ctags. The ctags entry in this chapter documents a different version of ctags, the Exuberant ctags.

Options


-a, --append

Append tag output to existing list of tags.


-C, --c++

Expect .c and .h files to contain C++, not C, code.


-d, --defines

Include tag entries for C preprocessor definitions.


--declarations

Create tags for function declarations and extern variables for C and similar languages.


-D, --no-defines

Do not include tag entries for C preprocessor definitions.


-g, --globals

In C, C++, Objective C, Java, and Perl, create tags for global variables. This is the default for etags.


-G, --no-globals

In C, C++, Objective C, Java, and Perl, do not create tags for global variables. This is the default for ctags.


-h, -H, --help

Print usage information.


-i file, --include=file

Add a note to the tags file that file should be consulted in addition to the normal input file.


--ignore-case-regex=regexp

Similar to --regex, except that case is not significant.


-I, --ignore-indentation

Do not assume that a closing brace in the first column ends a function or structure definition for C and C++.


-l language, --language=language

Consider the files that follow this option to be written in language. Use the -h option for a list of languages and their default filename extensions.


-m, --members

Create tags for members of structs and similar constructs in C++, Objective C and Java.


-M, --no-members

Do not create tags for members of structs and similar constructs in C++, Objective C and Java. This is the default.


-o file, --output=file

Write to file.


-r regexp, --regex=regexp

Include a tag for each line that matches regexp in the files following this option.


-R, --noregex

Don't include tags based on regular-expression matching for the files that follow this option.


-V, --version

Print the version number.

GNU ctags Options


-B, --backward-search

Create tags files using the ? backward search character, instead of the default / forward search character.


-t, --typedefs

Include typedefs in C. etags does this by default.


-T, --typedefs-and-c++

Include tags for typedefs, struct, enum, and union tags, and C++ member functions. etags does this by default.


-u, --update

Update the entries just for the named files, leaving other entries in place. It is likely to be faster to simply rebuild the entire tags file.


-v, --vgrind

Do not create a tags file. Instead, write the index in vgrind format. This is a rather obsolete option.


-w, --no-warn

Do not warn about duplicate entries.


-x, --cxref

Do not create a tags file. Instead, write a cross reference in cxref format to standard output. This option is also of only marginal use, as there is no standard cross-platform cxref program.

evim

     evim [options] [file ...]     eview [options] [file ...]

evim starts the graphical version of vim in "easy mode," whereby editing uses point-and-click. This makes vim feel like the very simple text editor found on some non-Unix operating systems. It should be used only by people who can't handle regular vim. eview is the same as evim but it starts up in read-only mode (equivalent to the -R option). See also vim and Chapter 9.

Solaris supplies evim in /opt/sfw/bin, and evim is installed by default if you build vim from source. On GNU/Linux, you can make a symbolic link named evim to gvim and it will work. On Mac OS X, you can link regular vim to evim, and it will work inside a terminal window. To access the ex prompt (so that you can exit, for example), type CTRL-O :.

URL: http://www.vim.org.

ex

     ex [options] files

A line-oriented text editor; a superset of ed and the root of vi. See Chapter 9 for more information.

expand

     expand [options] [files]

Expand tab characters into appropriate number of spaces. expand reads the named files or standard input if no files are provided. See also unexpand.

Options


-n

Set the tabstops every n characters. The default is 8.


-tablist

Interpret tabs according to tablist, a space- or comma-separated list of numbers in ascending order, that describe the "tabstops" for the input data.


-i, --initial

Convert tabs only at the beginning of lines.


-t tablist, --tabs tablist

Interpret tabs according to tablist, a space- or comma-separated list of numbers in ascending order, that describe the "tabstops" for the input data.

Example

Cut columns 10-12 of the input data, even when tabs are used:

     expand data | cut -c 10-12 > data.col2

expr

     expr arg1 operator arg2 [ operator arg3 ... ]

Evaluate arguments as expressions and print the result. Strings can be compared and searched. Arguments and operators must be separated by spaces. In most cases, an argument is an integer, typed literally or represented by a shell variable. There are three types of operators: arithmetic, relational, and logical. Exit status for expr is 0 (expression is nonzero and nonnull), 1 (expression is 0 or null), or 2 (expression is invalid).

expr is typically used in shell scripts to perform simple arithmetic, such as addition or subtraction. It is made obsolete in modern shells that have built-in arithmetic capabilities.

Arithmetic Operators

Use the following operators to produce mathematical expressions whose results are printed:

+

Add arg2 to arg1.

-

Subtract arg2 from arg1.

*

Multiply the arguments.

/

Divide arg1 by arg2.

%

Take the remainder when arg1 is divided by arg2.


Addition and subtraction are evaluated last, unless they are grouped inside parentheses. The symbols *, (, and ) have meaning to the shell, so they must be escaped (preceded by a backslash or enclosed in single or double quotes).

Relational Operators

Use relational operators to compare two arguments. Arguments can also be words, in which case comparisons assume a < z and A < Z. If the comparison statement is true, the result is 1; if false, the result is 0. Symbols < and > must be escaped.

=

Are the arguments equal?

!=

Are the arguments different?

>

Is arg1 greater than arg2 ?

>=

Is arg1 greater than or equal to arg2 ?

<

Is arg1 less than arg2 ?

<=

Is arg1 less than or equal to arg2 ?


Logical Operators

Use logical operators to compare two arguments. Depending on the values, the result can be arg1 (or some portion of it), arg2, or 0. Symbols | and & must be escaped.


|

Logical OR; if arg1 has a nonzero (and nonnull) value, the result is arg1; otherwise, the result is arg2.


&

Logical AND; if both arg1 and arg2 have a nonzero (and nonnull) value, the result is arg1; otherwise, the result is 0.


:

Similar to grep; arg2 is a pattern to search for in arg1. arg2 must be a regular expression in this case. If the arg2 pattern is enclosed in \( \), the result is the portion of arg1 that matches; otherwise, the result is simply the number of characters that match. By default, a pattern match always applies to the beginning of the first argument (the search string implicitly begins with a ^). To match other parts of the string, start the search string with .*.

Keywords

The GNU/Linux version accepts additional keyword commands. Some Unix versions of expr also accept the index, length, and substr keywords.


+ token

Treat token as a string, even if it would normally be a keyword or an operator.


index string character-list

Return the first position in string that matches the first possible character in character-list. Continue through character-list until a match is found, or return 0.


length string

Return the length of string.


match string regex

Same as string : regex.


substr string start length

Return a section of string, beginning with start, with a maximum length of length characters. Return null when given a negative or nonnumeric start or length.

Examples

Division happens first; result is 10:

     expr 5 + 10 / 2

Addition happens first; result is 7 (truncated from 7.5):

     expr \( 5 + 10 \) / 2

Add 1 to variable i; this is how variables are incremented in shell scripts:

     i='expr $i + 1'

Print 1 (true) if variable a is the string "hello":

     expr $a = hello

Print 1 (true) if variable b plus 5 equals 10 or more:

     expr $b + 5 \>= 10

In the following examples, variable p is the string "version.100". This command prints the number of characters in p :

     expr $p : '.*'         Result is 11

Match all characters and print them:

     expr $p : '\(.*\)'     Result is "version.100"

Print the number of lowercase letters at the beginning of p :

     expr $p : '[a-z]*'     Result is 7

Match the lowercase letters at the beginning of p :

     expr $p : '\([a-z]*\)' Result is "version"

Truncate $x if it contains five or more characters; if not, just print $x. (Logical OR uses the second argument when the first one is 0 or null; i.e., when the match fails.) Double-quoting is a good idea, in case $x contains whitespace characters:

     expr "$x" : '\(.....\)' \| "$x"

In a shell script, rename files to their first five letters:

     mv "$x" 'expr "$x" : '\(.....\)' \| "$x"'

(To avoid overwriting files with similar names, use mv -i.)

factor

     factor [num]

Solaris and GNU/Linux only. Produce the prime factors of num or read numbers from input.

false

     false

A do-nothing command that returns an unsuccessful (nonzero) exit status. Normally used in Bourne shell scripts. See also true.

false is built into most modern shells.

Examples

# This loop never executes     while false     do             commands     done     # This loop executes forever     until false     do             commands     done

fdformat

     fdformat [options] [device]

Solaris and GNU/Linux only.[*] Format floppy disks and PCMCIA memory cards. device is the name of the appropriate device to format, and varies considerably based on the density of the media, the capability of the disk drive, and on Solaris whether or not volume management is in effect.

[*] As Macintosh systems don't have floppy disk drives, this command would be of no use, anyway.

Solaris Options


-b label

Apply the label to the media. SunOS labels may be up to 8 characters; DOS labels may be up to 11 uppercase characters.


-B file

Install bootloader in file on an MS-DOS diskette. Can only be used with -d or -t dos.


-D

Format a 720KB (3.5 inch) or 360KB (5.25 inch) double-density diskette. Use on high- or extended-density drives.


-e

Eject floppy disk when done.


-E

Format a 2.88MB (3.5 inch) extended-density diskette.


-f

Force. Do not prompt for confirmation before formatting.


-H

Format a 1.44MB (3.5 inch) or 1.2MB (5.25 inch) high-density diskette. Use on extended-density drive.


-M

Use a 1.2MB (3.5 inch) medium-density format on a high-density diskette. Use only with the -t nec option.


-q

Quiet mode. Don't print status messages.


-t dos

Install an MS-DOS filesystem and boot sector formatting.


-t nec

Install an NEC-DOS filesystem and boot sector after formatting. Use only with -M.


-U

Unmount any filesystems on the media, and then format.


-v

Verify each block on the media after formatting.


-x

Don't format, just write a SunOS label or MS-DOS filesystem.

Solaris Compatibility Options

These options are for compatibility with previous versions of fdformat. Their use is discouraged.


-d

Same as -t dos.


-l

Same as -D.


-L

Same as -D.


-m

Same as -M.

GNU/Linux Option


-n

Do not verify format after completion.

fgrep

     fgrep [options] [pattern] [files]

Search one or more files for lines that match a literal, text-string pattern. Because fgrep does not support regular expressions, it is potentially faster than grep (hence fgrep, for fast grep). Exit status is 0 if any lines match, 1 if not, and 2 for errors. See also egrep and grep.

The options for fgrep are the same as for egrep, including the Solaris versus GNU differences. See egrep for the full list.

Examples

Print lines in file that don't contain any spaces:

     fgrep -v ' ' file

Print lines in file that contain the words in spell_list :

     fgrep -f spell_list file

file

     file [options] files

Classify the named files according to the type of data they contain. file checks the magic file (usually /etc/magic) to identify many common file types.

Many file types are understood. Output lists each filename, followed by a brief classification such as:

     ascii text     c program text     c shell commands     data     empty     iAPX 386 executable     directory     [nt]roff, tbl, or eqn input text     shell commands     symbolic link to ../usr/etc/arp

Mac OS X and GNU/Linux use the freely-available version of file from ftp://ftp.astron.com/pub/file/.

Solaris Options


-c

Check the format of the magic file (files argument is invalid with -c).


-d

Apply any default system tests that are position-dependent or context-dependent to the file.


-f listfile

Run file on the filenames in listfile.


-h

Do not follow symbolic links.


-i

For regular files, do not attempt to classify the file further. Instead, just print the message "regular file."


-m file

/usr/xpg4/bin/magic: same as -M.

/usr/bin/magic: use file as the magic file instead of /etc/magic.


-M file

file contains position-dependent or context-sensitive tests to apply.

Astron.com file Options


-b, --brief

Brief mode; do not prepend filenames to output lines.


-c, --checking-printout

Check the format of the magic file (files argument is invalid with -c). Usually used with -m.


-C, --compile

Create a magic.mgc file, which is a preparsed version of the magic file.


-f file, --files-from file

Read the names of files to be checked from file.


-F sep, --separator sep

Use sep as the separator between the filename and the type. The default is :.


-i, --mime

Produce MIME type strings instead of the traditional output.


-k, --keep-going

Keep going after the first match.


-L, --dereference

Follow symbolic links. By default, symbolic links are not followed.


-m filelist, --magic-file filelist

Search for file types in filelist instead of /usr/share/magic. filelist may be a single filename or a colon-separated list of files. If a compiled magic file is found, it is used. With -i, file appends .mime to each filename.


-n, --no-buffer

Flush standard output after checking a file.


-N, --no-pad

Do not pad filenames to make them align in the output.


-p, --preserve-date

Attempt to preserve the access times of read files so that it looks as if file never read them.


-r, --raw

Do not translate unprintable characters into their octal equivalents.


-s, --special-files

Read the contents of block or character device special files, instead of being merely content to display their type.


-v, --version

Print the version and exit.


-z, --uncompress

Attempt checking of compressed files.

Example

List all files that are deemed to be HTML input:

     file * | grep -i HTML

find

     find [options] pathname(s) condition(s)

An extremely useful command for finding particular groups of files (numerous examples follow this description). find descends the directory tree beginning at each pathname and locates files that meet the specified conditions. At least one pathname must be specified. The most useful conditions include -print, -name, and -type (for general use), -exec and -size (for advanced users), and -mtime and -user (for administrators).

On very old systems, you must supply at least one condition. If you don't, find traverses the pathnames but doesn't produce any output. Therefore, for highest portability, always provide -print.

Conditions may be grouped by enclosing them in \( \) (escaped parentheses), negated with ! (use \! in the C shell), given as alternatives by separating them with -o, or repeated (adding restrictions to the match; usually only for -name, -type, and -perm).

The find command can often be combined with the xargs command when there are too many files for naming on the command line. (See xargs.)

find is yet another example of a Unix command that has a core set of common abilities, with many system-specific extensions. Take careful note of which systems support which conditions.


Solaris and Mac OS X Options


-H

Only for files named on the command line, follow symbolic links, working with the information about the linked-to file, instead of the symbolic link itself.


-L

For all symbolic links, follow the link, working with the information about the linked-to file, instead of the symbolic link itself.

GNU/Linux Option


-daystart

Calculate times from the start of the day today, not 24 hours ago.

Mac OS X Options


-d

Do a depth-first traversal, directories being visited after their children (postorder). The default is a preorder traversal, with directories being visited before their children.


-E

Interpret regular expressions for -regex and -iregex as Extended Regular Expressions. (See Chapter 7.)


-f pathname

Descend pathname.


-P

For symbolic links, use information about the link itself, not the linked-to file. This is the default.


-s

Traverse file hierarchies in lexicographical order.


-x

Do not descend into directories on different devices (filesystems) from the one where the descent began.


-X

For use with xargs, complain if the filename contains an xargs delimiter character (any of single quote, double quote, backslash, space, tab, or newline). Such files are skipped.

Common Conditions


-atime + n | - n | n

Find files that were last accessed more than n (+n), less than n (-n), or exactly n days ago. Note that find will change the access time of directories supplied as pathnames.


-ctime + n | - n | n

Find files that were changed more than n (+n), less than n (-n), or exactly n days ago. Change refers to modification, permission or ownership changes, etc.; therefore, -ctime is more inclusive than -atime or -mtime.


-depth

Descend the directory tree, skipping directories and working on actual files first (and then the parent directories). Useful when files reside in unwritable directories (e.g., when using find with cpio).


-exec command { } \;

Run the Unix command on each file matched by find, provided command executes successfully on that file; i.e., returns a 0 exit status. When command runs, the argument { } is replaced with the name of the current file. Follow the entire sequence with an escaped semicolon (\;).


-follow

Follow symbolic links and track the directories visited (don't use this with -type l).


-fstype type

Find files that reside on filesystems of type type.


-group gname

Find files belonging to group gname, which can be a group name or a group ID number.


-inum n

Find files whose inode number is n.


-links n

Find files having n links.


-ls

Display matching files with associated statistics (as if run through ls -lids).


-mount

Search for files that reside only on the same filesystem as pathname. Solaris and GNU/Linux only. (On Mac OS X, use -xdev instead.)


-mtime + n | - n | n

Find files that were last modified more than n (+n), less than n (-n), or exactly n days ago.


-name pattern

Find files whose names match pattern. Filename metacharacters may be used, but should be escaped or quoted.


-newer file

Find files that have been modified more recently than file; similar to -mtime.


-nogroup

Find files belonging to a group not in /etc/group.


-nouser

Find files owned by a user not in /etc/passwd.


-ok command { } \;

Same as -exec, but user must respond (with a y) before command is executed.


-perm nnn

Find files whose permission settings (e.g., rwx) match octal number nnn exactly (e.g., 664 matches -rw-rw-r--). Use a minus sign to make a wildcard match of any specified bit (e.g., -perm -600 matches -rw*******, where * can be any mode). Some systems also allow +nnn for this purpose.

Solaris allows nnn to be a symbolic mode in the same form as allowed by chmod.


-print

Print the matching files and directories, using their full pathnames. On modern systems, this is the default action.


-prune

"Prune" the directory tree of unwanted directory searches; that is, skip the directory most recently matched.


-size n[c ]

Find files containing n blocks, or, if c is specified, files that are n characters (bytes) long. (One block = 512 bytes). Some systems allow nk to specify the size in kilobytes.


-type c

Find files whose type is c. c can be:

b

Block special file

c

Character special file

d

Directory

D

Door special file, Solaris and GNU version only

f

Plain file

l

Symbolic link

p

Fifo or named pipe

s

Socket



-user user

Find files belonging to a user name or ID.


-xdev

Same as -mount.

GNU/Linux and Mac OS X Conditions


-amin +n | - n | n

Find files last accessed more than n (+n), less than n (-n), or exactly n minutes ago.


-anewer file

Find files that were accessed after file was last modified. Affected by -follow when after -follow on the command line.


-cmin +n | - n | n

Find files last changed more than n (+n), less than n (-n), or exactly n minutes ago.


-cnewer file

Find files that were changed after they were last modified. Affected by -follow when after -follow on the command line.


-empty

Continue if file is empty. Applies to regular files and directories.


-false

Return false value for each file encountered.


-iname pattern

A case-insensitive version of -name.


-ipath pattern

A case-insensitive version of -path.


-iregex pattern

A case-insensitive version of -regex.


-maxdepth num

Do not descend more than num levels of directories.


-mindepth num

Begin applying tests and actions only at levels deeper than num levels.


-mmin +n | - n | n

Find files last modified more than n (+n), less than n (-n), or exactly n minutes ago.


-not expr

Same as ! expr.


-path pattern

Find files whose names match pattern. Expect full pathnames relative to the starting pathname (i.e., do not treat / or . specially).


-print0

Like -print, but terminate the pathname with a zero byte. This allows programs that read filenames to interpret them unambiguously. See also xargs.


-regex pattern

Like -path, but uses grep-style regular expressions instead of the shell-like globbing used in -name and -path.

Solaris Conditions


-acl

True if the file has ACLs (Access Control Lists) defined.


-cpio dev

Take matching files and write them on device dev, using cpio. Obsolete.


-local

Find files that physically reside on the local system.


-ncpio dev

Take matching files and write them on device dev, using cpio -c. Obsolete.


-xattr

True if the file has extended attributes.

GNU/Linux Conditions


-context scontext, --context scontext

File has security context scontext. SELinux only.


-fls file

Like -ls, but send output to file.


-fprint file

Like -print, but send output to file.


-fprint0 file

Like -print0, but send output to file.


-fprintf file format

Like -printf, but send output to file.


-gid num

Find files with numeric group ID of num.


-ilname pattern

A case-insensitive version of -lname.


-lname pattern

Search for files that are symbolic links, pointing to files named pattern. pattern can include shell metacharacters and does not treat / or . specially. The match is case-insensitive.


-noleaf

Normally, find assumes that each directory has at least two hard links that should be ignored (a hard link for its name and one for "."; i.e., two fewer "real" directories than its hard link count indicates). -noleaf turns off this assumption, a useful practice when find runs on non-Unix-style filesystems. This forces find to examine all entries, assuming that some might prove to be directories into which it must descend (a time-waster on Unix).


-printf format

Print using format to standard output. Interpret escape sequences and special formatting control sequences that begin with %. See the manpage for the full details.


-true

Return true value for each file encountered.


-uid num

Find files with numeric user ID of num.


-used num

File was accessed num days after it was modified.


-xtype c

Like -type except for symbolic links. For symbolic links, this checks the type of the linked-to file. However, with -follow, find checks the link itself, and this condition will be true only if c is l.

Mac OS X Conditions


-delete

Delete found files or directories. Always returns true. Use with extreme caution.


-execdir command { } \;

Like -exec, but execute the command from within the directory holding the current file. The filename substituted for { } is not fully qualified.


-flags [+ |- ]flags, notflags

Check that the given flags are set and that the notflags (flag names prefixed with no) are not set. The flags are those managed by chflags. With a leading -, the condition evaluates to true if at least all the bits in flags must be set and all the bits in notflags must be clear. With a leading +, the condition evaluates to true if any of the bits in flags are set and any of the bits in notflags are clear. Otherwise, the file's flags must exactly match the combination of flags and notflags.


-mnewer file

Same as -newer.


-newerXY file

Compare the attribute X of the current file against the attribute Y of file. Values for X and Y may be a for the access time, c for the inode change time, or m for the modification time. Additionally, Y may be t, in which case file is expected to be a date specification as understood by CVS. (See Chapter 14.)


-okdir command { } \;

Like -ok, but execute the command from within the directory holding the current file. The filename substituted for { } is not fully qualified.

Examples

List all files (and subdirectories) in your home directory:

     find $HOME -print

List all files named chapter1 underneath the /work directory:

     find /work -name chapter1 -print

List "memo" files owned by ann (note the use of multiple starting paths):

     find /work /usr -name 'memo*' -user ann -print

Search the filesystem (begin at root) for manpage directories:

     find / -type d -name 'man*' -print

Search the current directory, look for filenames that don't begin with a capital letter, and send them to the printer:

     find . \! -name '[A-Z]*' -exec lp {  } \;

Find and compress files whose names don't end with .gz:

     gzip 'find . -type f \! -name '*.gz' -print'

Remove all empty files on the system (prompting first):

     find / -size 0 -ok rm {  } \;

Skip RCS directories, but list remaining read-only files:

     find . -name RCS -prune -o -perm 444 -print

Search the system for files that were modified within the last two days (good candidates for backing up):

     find / -mtime -2 -print

Recursively grep for a pattern down a directory tree:

     find /book -print | xargs grep '[Nn]utshell'

finger

     finger [options] users

Display data about one or more users, including information listed in the files .plan and .project in user's home directory. You can specify each user either as a login name (exact match) or as a first or last name (display information on all matching names). Networked environments recognize arguments of the form user@host and @host. (Today, many systems on the Internet disallow connections from finger requests.)

Common Options


-l

Force long format (default).


-m

users must match usernames exactly, instead of also searching for a match of first or last names.


-p

Omit .plan file from display. On Mac OS X, this also omits the .forward, .project, and .pubkey files.


-s

Show short format.

Solaris Options


-b

Omit user's home directory and shell from display.


-f

Used with -s to omit heading that normally displays in short format.


-h

Omit .project file from display.


-i

Show "idle" format, a terse format (like -s).


-q

Show "quick" format, the tersest of all (requires an exact match of username).


-w

Use with -s to omit user's full name that normally displays in short format.

Mac OS X Options


-4

Use only IPv4 addresses.


-6

Use only IPv6 addresses.


-g

Display only the user's real name from the gecos information.


-h

Together with -s, display the remote host information instead of the office information.


-o

Together with -s, display only the office information.


-T

Don't piggyback data with the initial connection request. Needed for some servers with broken TCP/IP implementations.

flex

     flex [options] [file]

flex (Fast Lexical Analyzer Generator) is a faster variant of lex. It generates a lexical analysis program (named lex.yy.c) based on the regular expressions and C statements contained in one or more input files. See also lex, bison, yacc, and lex & yacc, cited in the Bibliography.

URL: http://www.gnu.org/software/flex.

Options


-b

Generate backup information to lex.backup.


-B

Generate a batch (noninteractive) scanner.


-c

Ignored; for POSIX compliance only.


-C

Compress scanner tables but do not use equivalence classes or metaequivalence classes.


-Ca

Align tables for memory access and computation. This creates larger tables but gives faster performance.


-Ce

Construct equivalence classes. This creates smaller tables and sacrifices little performance (default).


-Cf

Generate full scanner tables, not compressed.


-CF

Generate faster scanner tables, like -F.


-Cm

Construct metaequivalence classes (default).


-Cr

Bypass use of the standard I/O library; use read(2) system calls instead.


-d

Debug mode.


-f

Create a faster but larger scanner.


-F

Use the fast scanner table representation.


-h, -?, --help

Help summary.


-i

Create a case-insensitive scanner.


-I

Generate an interactive scanner (default).


-l

Maximum lex compatibility.


-L

Suppress #line directives in lex.yy.c.


-n

Ignored; for POSIX compliance only.


-o file

Write output to file instead of lex.yy.c.


-p

Print performance report to standard error.


-P prefix

Change default yy prefix to prefix for all globally visible variable and function names.


-s

Create a scanner that exits if it encounters input that does not match any of its rules.


-S skeleton_file

Use skeleton_file for the code skeleton, instead of the default file. This option is mainly for use by the flex maintainers.


-t

Print to standard output. (By default, flex prints to lex.yy.c.)


-T

Run in trace mode. This produces considerable output, which is mainly of use to the flex maintainers.


-v

Print a summary of statistics to standard error.


-V, --version

Print version information and exit.


-w

Suppress warning messages.


-7

Generate a seven-bit scanner.


-8

Generate an eight-bit scanner (default).


-+

Generate a C++ scanner class.

fmt

     fmt [options] [files]

Fill and join text, producing lines of roughly the same length. (Unlike nroff, the lines are not justified.) fmt ignores blank lines and lines beginning with a dot (.) or with "From:". The emacs editor uses ESC-q to join paragraphs, so fmt is useful for other editors, such as vi. The following vi command fills and joins the remainder of the current paragraph:

     !}fmt

Solaris Options


-c

Don't adjust the first two lines; align subsequent lines with the second line. Useful for paragraphs that begin with a hanging tag.


-s

Split long lines but leave short lines alone. Useful for preserving partial lines of code.


-w n

Create lines no longer than n columns wide. Default is 72. (Can also be invoked as -n for compatibility with BSD.)

GNU/Linux Options


-c, --crown-margin

Crown margin mode. Do not change indentation of each paragraph's first two lines. Use the second line's indentation as the default for subsequent lines.


-p prefix, --prefix=prefix

Format only lines beginning with prefix.


-s, --split-only

Suppress line-joining.


-t, --tagged-paragraph

Tagged paragraph mode. Same as crown mode when the indentations of the first and second lines differ. If the indentation is the same, treat the first line as its own separate paragraph.


-u, --uniform-spacing

Reduce spacing to a maximum of one space between words and two between sentences.


-w width, --width=width

Set output width to width. The default is 75.

Mac OS X Options


-c

Center each line of text. Most other options are ignored, and no splitting or joining of lines is done.


-d charlist

Treat the characters in charlist as sentence-ending characters. The default list is .?! (period, question mark, and exclamation mark).


-l count

Replace each count spaces at the beginning of a line with a tab character. The default is eight. If count is zero, spaces are preserved.


-m

Attempt to sensibly format mail header lines.


-n

Format lines that begin with . (dot). Normally, for nroff compatibility, fmt leaves such lines alone.


-p

Allow indented paragraphs. Normally changes in leading whitespace start a new output paragraph. This option disables that behavior.


-s

Condense multiple whitespace characters inside lines into single spaces.


-t count

Assume that input files use count spaces per tab stop. The default is eight.

ftp

     ftp [options] [hostname]

Transfer files to and from remote network site hostname. ftp prompts the user for a command. Type help to see a list of known commands.

Common Options


-d

Enable debugging.


-e

Disable command-line editing and history. GNU/Linux and Mac OS X only.


-g

Disable filename expansion (globbing).


-i

Turn off interactive prompting.


-n

No auto-login upon initial connection.


-p

Use passive mode for transfering data.


-v

Verbose on. Show all responses from remote server.

Solaris Options


-a

Use GSSAPI authentication. If authentication fails, close the connection.


-v

Forward local security credentials to the server.


-m GSSAPI-mech

Use the provided GSSASPI mechanism. For details see mech(4).


-t

Enable packet tracing. This option is not yet implemented.


-T timeout

Use timeout in seconds for the global connection timer.


-x

Use GSSAPI for authentication and encryption.

Mac OS X Options


-4

Use only IPv4 addresses.


-6

Use only IPv6 addresses.


-a

Use anonymous login instead of the normal login procedure.


-A

Force active mode FTP. The default is passive mode.


-f

Force a cache reload when a transfer goes through an FTP or HTTP proxy.


-N netrc-file

Use the given file instead of $HOME/.netrc.


-o file

Save the first automatically retrieved file to file, unless file is - or starts with |. See the manpage for more details.


-P port

Use port number port.


-r count

When a connection attempt fails, wait count seconds and then retry.


-R

Restart all nonproxied auto-fetches.


-t

Enable packet tracing.


-T direction, max[, incr]

Set the maximum transfer rate in direction to max bytes/second. If given, set the increment to incr. See the manpage for more information.


-u url file ...

Upload one or more files to url.


-v

Enable the verbose and progress commands. This is the default when output is to a terminal.


-V

Disable the verbose and progress commands.

g++

     g++ [options] files

Invoke gcc with the options necessary to make it recognize C++. g++ recognizes all the file extensions gcc does, in addition to C++ source files (.C, .cc, .cpp, or .cxx files) and C++ preprocessed files (.ii files). See also gcc.

gcc

     gcc [options] files

GNU Compiler Collection. gcc, formerly known as the GNU C Compiler, compiles multiple languages (C, C++, Objective-C, Ada, Fortran, and Java) to machine code. Here we document its use to compile C, C++, or Objective-C code. gcc compiles one or more program source files; for example, C source files (file.c), assembler source files (file.s), or preprocessed C source files (file.i). If the file suffix is not recognizable, assume that the file is an object file or library. gcc normally invokes the C preprocessor, compiles the preprocessed code to assembly language code, assembles it, and then links it with the linker. This process can be stopped at one of these stages using the -c, -S, or -E option. The steps may also differ depending on the language being compiled. By default, output is placed in a.out. In some cases, gcc generates an object file having a .o suffix and a corresponding root name.

Preprocessor and linker options given on the gcc command line are passed on to these tools when they are run. These options are briefly described here, but some are more fully described under the entry for ld. The options that follow are divided into general, preprocessor and linker options. We have included only the most generally useful options. gcc accepts many, many more options not covered here.

gcc is the GNU form of cc; on most Linux systems, the command cc invokes gcc. The command g++ invokes gcc with the appropriate options for interpreting C++; see g++.


URL: http://gcc.gnu.org.

General options


-a

Provide profile information for basic blocks.


-ansi

Enforce full ANSI conformance.


-c

Create linkable object file for each source file, but do not call the linker.


-E

Preprocess the source files, but do not compile. Print result to standard output. This option is useful to meaningfully pass some cpp options that would otherwise break gcc, such as -C, -M, or -P.


-foption

Set the specified compiler option. Many of these control debugging, optimization of code, and special language options. Use the --help -v options for a full listing.


-g

Include debugging information for use with gdb.


-glevel

Provide level amount of debugging information. level must be 1, 2, or 3, with 1 providing the least amount of information. The default is 2.


--help

Print most common basic options, then exit. When used with option -v, print options for all of gcc's subprocesses. For options specific to a target, use --target-help.


-moption

Set the specified machine specific option. Use the --target-help option for a full listing.


-o file

Specify output file as file. Default is a.out.


-O[ level]

Optimize. level should be 1, 2, 3, or 0 (the default is 1). 0 turns off optimization; 3 optimizes the most.


-p

Provide profile information for use with prof.


-pedantic

Warn verbosely.


-pg

Provide profile information for use with gprof.


-std=standard

Specify C standard of input file. Accepted values are:

iso9899:1990, c89

1990 ISO C standard.

iso9899:199409

1994 amendment to the 1990 ISO C standard.

iso9899:1999, c99, iso9899:199x, c9x

1999 revised ISO C standard.

gnu89

1990 C Standard with GNU extensions (the default value).

gnu99, gnu9x

1999 revised ISO C standard with GNU extensions.



-S

Compile source files into assembler code, but do not assemble.


-v

Print version information.


-V version

Attempt to run gcc version version.


-w

Suppress warnings.


-W

Warn more verbosely than normal.


-Wall

Enable almost all possible warnings. See the manpage for a detailed list of available warnings.


-x language

Expect input file to be written in language, which may be c, objective-c, c-header, c++, ada, f77, ratfor, assembler, java, cpp-output, c++-cpp-output, objc-cpp-output, f77-cpp-output, assembler-with-cpp, or ada. If none is specified as language, guess the language by filename extension.

Preprocessor options

gcc passes the following options to the preprocessor:


-Dname[= def]

Define name with value def as if by #define. If no =def is given, name is defined with value 1. -D has lower precedence than -U.


-Idir

Include dir in list of directories to search for include files. If dir is -, search those directories specified by -I before the -I- only when #include "file" is specified, not #include <file>.


-M, -MG, -MF, -MD, -MMD, -MQ, -MT

Suppress normal output and print Makefile rules describing file dependencies. Print a rule for make that describes the main source file's dependencies. If -MG is specified, assume that missing header files are actually generated files, and look for them in the source file's directory. Most of these options imply -E.


-trigraphs

Convert special three-letter sequences, meant to represent missing characters on some systems, into the single character they represent.


-Uname

Remove definition of symbol name.

Linker options

gcc passes the following options to the linker:


-llib

Link to lib.


-Ldir

Search dir in addition to standard directories for libraries.


-s

Remove all symbol table and relocation information from the executable.


-u symbol

Force the linker to search libraries for a definition of symbol, and to link to the libraries found.

gcore

     gcore [option] process_ids

Solaris and GNU/Linux only. Create ("get") a core image of each running process specified. The core image can be used with a debugger. You must own the running process or be a privileged user to use this command.

Common Option


-o file

Place the output in a file named file.process_id (default is core.process_id).

Solaris Options


-c content

Place content in the core file. See coreadm(1M) for details on the values of content.


-F

Force; take control of pid even if another process had control of it.


-g

Produce a core file in the global repository with global content as configured via coreadm(1M). You must have permission to create files in the global core repository.


-p

Produce a core file in the process-specific repository with process-specific content as configured via coreadm(1M). You must have permission to create files in the process-specific core repository.

gdb

     gdb [options] [program [core | pid]]

GDB (the GNU DeBugger) allows you to step through the execution of a program in order to find the point at which it breaks. It supports a number of languages. The program to be debugged is normally specified on the command line; you can also specify a core file or, if you want to investigate a running program, a process ID. For more information, see Chapter 17.

getconf

     getconf [-v spec] system_var     getconf [-v spec] path_var path     getconf -a

This command is specified by POSIX as a portable way of determining system limits. In the first form, print the value of system configuration variables . In the second, print the value of filesystem-related parameters . In the third, print the values of all system configuration variables.

Options


-a

Print the names and values of all system configuration variables. Solaris only.


-v spec

Use spec to govern the selection of values for configuration variables.

getopts

     getopts string name [arg]

Same as built-in Bash and ksh shell command getopts. See Chapter 4.

gettext

     gettext [options] [domain] string

Solaris and GNU/Linux only. Retrieve and print the translated version of string. This provides shell-level access to the facilities of gettext (3C). Translations are looked up in the file lang/LC_MESSAGES/domain.mo in the system's translation directory. lang is the current locale (e.g., en_US). If domain is not supplied, the value of $TEXTDOMAIN is used instead. Without a domain, or if no translation can be found, gettext simply prints string. If $TEXTDOMAINDIR exists, its value is used instead of the system default.

The GNU version of gettext and the accompanying commands and library functions are an extension of the original Solaris design from the early 1990s. Modern Solaris versions of the commands have picked up some of the features first developed for the GNU version. Thus, for example, even the Solaris version of this command accepts long options.


URL: http://www.gnu.org/software/gettext .

Options


-d domain, --domain=domain

Retrieve messages from the domain text domain.


-e

Enable expansion of some escape sequences. Use with -s.


-h, --help

Print a command-line summary and exit. GNU/Linux only.


-n

Don't print the trailing newline. Use with -s.


-s

Enable echo-like features (-e and -n).


-V, --version

Print version information and exit. GNU/Linux only.

ghostscript

     ghostscript [options] files

GhostScript, an interpreter for Adobe Systems' PostScript and PDF (Portable Document Format) languages. Used for document processing. With - in place of files, standard input is used. The usual name is gs; see gs.

gprof

     gprof [options] [objfile [pfile]]

Display call-graph profile data of C programs. Programs compiled with the -xpg option of Sun's cc (-pg on other compilers) produce a call-graph profile file pfile, whose default name is gmon.out. The specified object file objfile (a.out by default) contains a symbol table that is read and correlated with pfile.

URL: http://www.gnu.org/software/binutils for the GNU version of gprof.

Common Options


-a, --no-static

Don't print statically declared functions.


-b, --brief

Brief; don't print field descriptions in the profile.


-c, --static-call-graph

Find the program's static call-graph. Call counts of 0 indicate static-only parents or children.


-e name

Don't print the graph profile entry for the routine name. -e may be repeated.


-E name

Like -e. In addition, during time computations, omit the time spent in name.


-f name

Print the graph profile entry only for routine name. -f may be repeated.


-F name

Like -f. In addition, during time computations, use only the times of the printed routines. -F may be repeated, and it overrides -E.


-s, --sum

With this option, you supply one or more existing pfiles. Sum the information in all specified profile files and send it to a profile file called gmon.sum. Useful for accumulating data across several runs.


-z, --display-unused-functions

Show routines that have zero usage. Useful with -c to find out which routines were never called.

Solaris Options


-n

Only print the top n functions.


-C

Demangle C++ symbol names before printing them out.


-D

With this option, you supply one or more existing pfiles. Process the information in all specified profile files and produce a profile file called gmon.sum that shows the difference between the runs. See also the -s option.


-l

Don't print entries for local symbols.

GNU/Linux Options


-A[ symspec], --annotated-source[= symspec]

Print annotated source code.


-C[ symspec], --exec-counts[= symspec]

Print statistics on the number of times each function is called. When used with option -l, count basic-block execution.


-d [ num], --debug[= num]

Turn on debugging. Use num to specify specific debugging features; otherwise enable all debugging. See the gprof Info file for more information.


-D, --ignore-non-functions

Ignore symbols that are not known functions. This produces more accurate profiles.


--demangle[= style], --no-demangle

Specify whether C++ symbols should be demangled or not. They are demangled by default. If profiling a program built by a different compiler, you may need to specify the mangling style.


--file-ordering file

Print suggested link line order for .o files based on profiling data. Read function name to object file mappings from file. This file can be created using the nm command.


--function-ordering

Print suggested function order based on profiling data.


-i, --file-info

Print summary information on data files, then exit.


-I dirs, --directory-path=dirs

Set directory path to search for source files. The dirs argument may be given as a colon-separated list of directories.


-J[ symspec], --no-annotated-source[= symspec]

Don't print annotated source code.


-k from/to

Remove arcs between the routines from and to.


-l, --line

Generate line-by-line profiles. This can increase gprof's running time and may be less statistically accurate.


-L, --print-path

Print the path information when printing filenames.


-m n, --min-count[= n]

Don't print count statistics for symbols executed less than n times.


-n[ symspec], --time[= symspec]

Propagate time statistics in call graph analysis.


-N[ symspec], --no-time[= symspec]

Don't propagate time statistics in call graph analysis.


-O format, --file-format[= format]

Use format for the output file format. Acceptable values are auto (the default), bsd, 4.4bsd, magic, and prof (not yet implemented).


-p[ symspec], --flat-profile[= symspec]

Print profile statistics.


-P[ symspec], --no-flat-profile[= symspec]

Don't print profile statistics.


-q[ symspec], --graph[ =symspec]

Print call graph analysis.


-Q[ symspec], --no-graph[= symspec]

Don't print call graph analysis.


-T, --traditional

Print output in BSD style.


-v, --version

Print version and exit.


-w n, --width=n

Print function index formatted to width n.


-x, --all-lines

When printing annotated source, annotate every line in a basic block, not just the beginning.


-y, --separate-files

Print annotated-source output to separate files instead of standard output. The annotated source for each source file is printed to filename-ann.


-Z[ symspec], --no-exec-counts[= symspec]

Don't print statistics on the number of times each function is called.

Mac OS X Options


-S

Create the "order" files gmon.order, callf.order, callo.order, and time.order, for use with ld. To include library functions in the files, you must have a whatsloaded file from ld in the current directory. For more details see ld(1).

grep

     grep [options] regexp [files]

Search one or more files for lines that match a regular expression regexp. Regular expressions are described in Chapter 7. Exit status is 0 if any lines match, 1 if not, and 2 for errors. See also egrep and fgrep.

Options

The options for grep are the same as for egrep, including the Solaris versus GNU differences. For Solaris, there is an exception: /usr/xpg4/bin/grep also accepts the -q option. See egrep for the full list.

Examples

List the number of users who use the C shell:

     grep -c /bin/csh /etc/passwd

List header files that have at least one #include directive:

     grep -l '^#include' /usr/include/*

List files that don't contain pattern :

     grep -c pattern files | grep :0

groff

     groff [options] [files]

The GNU version of troff. Formats documents to screen or for laser printing. See Chapter 18.

groups

     groups [options] [user]

Show the groups that user belongs to (default is your groups). Groups are listed in /etc/passwd and /etc/group.

gs

     gs [options] [files]

Solaris (in /usr/sfw/bin), and GNU/Linux only. GhostScript, an interpreter for Adobe Systems' PostScript and PDF (Portable Document Format) languages. Used for document processing. With - in place of files, standard input is used.

URLs: http://www.gnu.org/software/ghostscript and http://www.cs.wisc.edu/~ghost/.

Options


-- filename arg1 ...

Take the next argument as a filename, but use all remaining arguments to define ARGUMENTS in userdict (not systemdict) as an array of those strings before running the file.


-Dname= token, -dname= token

Define a name in systemdict with the given definition. The token must be exactly one token (as defined by the token operator) and must not contain any whitespace.


-Dname, -dname

Define a name in systemdict with a null value.


-gnumber1x number2

Specify width and height of device; intended for systems like the X Window System.


-Idirectories

Add the designated list of directories at the head of the search path for library files.


-q

Quiet startup.


-rnumber, -rnumber1xnumber2

Specify X and Y resolutions (for the benefit of devices, such as printers, that support multiple X and Y resolutions). If only one number is given, it is used for both X and Y resolutions.


-Sname= string, -sname= string

Define a name in systemdict with a given string as value.

Special names


-dDISKFONTS

Causes individual character outlines to be loaded from the disk the first time they are encountered.


-dNOBIND

Disables the bind operator. Useful only for debugging.


-dNOCACHE

Disables character caching. Useful only for debugging.


-dNODISPLAY

Suppresses the normal initialization of the output device. May be useful when debugging.


-dNOPAUSE

Disables the prompt and pause at the end of each page.


-dNOPLATFONTS

Disables the use of fonts supplied by the underlying platform (e.g., the X Window System).


-dSAFER

Disables the deletefile and renamefile operators and the ability to open files in any mode other than read-only.


-dWRITESYSTEMDICT

Leaves systemdict writable.


-sDEVICE=device

Selects an alternate initial output device.


-sOUTPUTFILE=filename

Selects an alternate output file (or pipe) for the initial output device.

gunzip

     gunzip [gzip   options] [files]

Identical to gzip -d. Typically provided as a hard link to gzip. The -1 ... -9 and corresponding long-form options are not available with gunzip; all other gzip options are accepted. See gzip for more information.

gzcat

     gzcat [gzip options] [files]

A link to gzip instead of using the name zcat, which preserves zcat's original link to the old compress command. Its action is identical to gunzip -c. May be installed as zcat on some systems. See gzip for more information.

gzip

     gzip [options] [files]

GNU Zip. Reduce the size of one or more files using Lempel-Ziv (L Z 7 7) coding, and move to file.gz. Restore with gunzip. With a filename of -, or with no files, gzip reads standard input. Usually, compression is considerably better than that provided by the old compress command. Furthermore, the algorithm is patent-free. Today, gzip is the de-facto compression software used throughout the Internet. (Although bzip2 is also popular, see bzip2.)

gzip ignores symbolic links. The original file's name, permissions, and modification time are stored in the compressed file, and restored when the file is uncompressed. gzip is capable of uncompressing files that were compressed with compress, pack, or the BSD compact. Default options may be placed in the environment variable GZIP.

gunzip is equivalent to gzip -d. It is typically a hard link to the gzip command. gzcat and zcat are equivalent to gunzip -c, and are also often hard links to gzip.

Additional related commands include gzcmp, which compares the contents of gzipped files; gzdiff, which creates diff (difference) files from a pair of gzip files; gzgrep, to search them; and the gzless and gzmore commands, which apply the more and less commands to gzip output as gzcat does with the cat command. See cat, cmp, diff, grep, less, and more for information on how to use those commands.

URL: http://www.gzip.org.

Options


-a, --ascii

ASCII text mode: convert end-of-lines using local conventions. Not supported on all systems.


-c, --stdout, --to-stdout

Write output on standard output; keep original files unchanged. Individual input files are compressed separately; for better compression, concatenate all the input files first.


-d, --decompress, --uncompress

Decompress.


-f, --force

Force. The file is compressed or decompressed, even if the target file exists or if the file has multiple links.


-h, --help

Display a help screen and exit.


-l, --list

List the compressed and uncompressed sizes, the compression ratio, and the original name of the file for each compressed file. With --verbose, also list the compression method, the 32-bit CRC, and the original file's last-modification time. With --quiet, the title and totals lines are not displayed.


-L, --license

Display the gzip license and quit.


-n, --no-name

For gzip, do not save the original filename and modification time in the compressed file. For gunzip, do not restore the original name and modification time; use those of the compressed file (this is the default).


-N, --name

For gzip, save the original filename and modification time in the compressed file (this is the default). For gunzip, restore the original filename and modification time based on the information in the compressed file.


-q, --quiet

Suppress all warnings.


-r, --recursive

Recursively walk the current directory tree and compress (for gunzip, uncompress) all files found.


--rsyncable

Make an archive that is "friendly" to rsync. Not supported on all systems.


-S .suf, --suffix .suf

Use .suf as the suffix instead of .gz. A null suffix makes gunzip attempt decompression on all named files, no matter what their suffix.


-t, --test

Check the compressed file integrity.


-v, --verbose

Display the name and percentage reduction for each file compressed or decompressed.


-V, --version

Display the version number and compilation options, and then quit.


-n, --fast, --best

Control the compression method. n is a number between 1 and 9. -1 (same as --fast) gives the fastest, but least compressed method. -9 (same as --best) gives the best compression, but is slower. Values between 1 and 9 vary the tradeoff in compression method. The default compression level is -6, which gives better compression at some expense in speed. In practice, the default is excellent, and you should not need to use these options.

head

     head [options] [files]

Print the first few lines of one or more files (default is 10).

Common Options


-n

Print the first n lines of the file. This is traditional head behavior, although it is not blessed by all versions of the POSIX standard.


-n n

Print the first n lines of the file.

GNU/Linux Options


-c num[b|k|m ], --bytes num[b|k|m ]

Print first num bytes or, if num is followed by b, k, or m, first num 512-byte blocks, 1-kilobyte blocks, or 1-megabyte blocks.


--lines num

Same as -n.


-q, --quiet, --silent

Quiet mode; never print headers giving filenames.


-v, --verbose

Print filename headers, even for only one file.

Examples

Display the first 20 lines of phone_list :

     head -n 20 phone_list

Display the first 10 phone numbers having a 202 area code:

     grep '(202)' phone_list | head

hexdump

     hexdump [options] file

GNU/Linux and Mac OS X only. Display specified file or input in hexadecimal, octal, decimal, or ASCII format. Option flags specify the display format.

Options


-b

Use a one-byte octal display, meaning the input offset is in hexadecimal and followed by sixteen three-column octal data bytes, filled in with zeroes and separated by spaces.


-c

Use a one-byte character display, meaning the input offset is in hexadecimal and followed by sixteen three-column entries, filled in with zeroes and separated with spaces.


-C

Canonical mode. Display hexadecimal offset, two sets of eight columns of hexadecimal bytes, then a | followed by the ASCII representation of those same bytes.


-d

Use a two-byte decimal display. The input offset is again in hexadecimal, but the display has only eight entries per line, of five columns each, containing two bytes of unsigned decimal format.


-e format_string

Choose a format string to be used to transform the output data. Format strings consist of:


Iteration count

The iteration count is optional. It determines the number of times to use the transformation string. The number should be followed by a slash character (/) to distinguish it from the byte count.


Byte count

The number of bytes to be interpreted by the conversion string. It should be preceded by a slash character to distinguish it from the iteration count.


Format characters

The actual format characters should be surrounded by quotation marks and are interpreted as printf(3) formatting strings (see also printf), although the *, h, l, n, p, and q options will not work as expected. Format string usage is discussed at greater length in the hexdump manpage.


-f filename

Choose a file that contains several format strings. The strings should be separated by newlines; the # character marks a line as a comment.


-n length

Limit the number of bytes of input to be interpreted.


-o

Two-byte octal display, meaning a hexadecimal offset followed by eight five-column data entries of two bytes each, in octal format.


-s offset

Skip to specified offset. The offset number is assumed to be decimal unless it starts with 0x or 0X (hexadecimal), or O (octal). Numbers may also be designated in megabytes, kilobytes, or half-kilobytes with the addition of m, k, or b at the end of the number.


-v

Display all input data, even if it is the same as the previous line. Normally, a duplicate line is replaced by an asterisk (*).


-x

Display data in a two-byte hexadecimal format. The offset is, as usual, in hexadecimal, and is followed by eight space-separated entries, each of which contains four-column, two-byte chunks of data in hexadecimal format.

hostname

     hostname [option] [nameofhost]

Set or print name of current host system. A privileged user can set the hostname with the nameofhost argument.

Mac OS X accepts the -s option.

GNU/Linux Options


-a, --alias

Display the alias name of the host (if used).


-d, --domain

Print DNS domain name.


-f, --fqdn, --long

Print fully qualified domain name.


-F file, --file file

Consult file for hostname.


-i, --ip-address

Display the IP address(es) of the host.


-n, --node

Display or set the DECnet node name. Not available on all systems. (And not terribly useful even on those systems that have it.)


-s, --short

Trim domain information from the printed name.


-v, --verbose

Verbose mode.


-y, --yp, --nis

Display the NIS domain name. A privileged user can set a new NIS domain name with nameofhost.

iconv

     iconv [options] -f from_encoding -t to_encoding [file]

Convert the contents of file from one character set to another.

Common Options


-c

Omit invalid output characters.


-f code1, --from-code=code1

Convert input characters from the code1 encoding.


-l, --list

Print a list of valid encodings to standard output.


-s, --silent

Operate silently; don't print warning messages.


-t code2, --to-code=code2

Convert input characters to the code2 encoding.

GNU/Linux Options


-o file, --output=file

Write the converted output to file instead of standard output.


--usage

Print a brief usage message showing only the command syntax and then exit.


-V, --version

Print version information and exit.


--verbose

Operate verbosely; print progress messages.


-?, --help

Print a help message and exit.

id

     id [options] [username]

Display information about yourself or another user: user ID, group ID, effective user ID and group ID if relevant, and additional group IDs.

Common Options


-g, --group

Print group ID only.


-G, --groups

Print supplementary groups only.


-n, --name

With -u, -g, or -G, print user or group name, not number.


-r, --real

With -u, -g, or -G, print real, not effective, user ID or group ID.


-u, --user

Print user ID only.

Solaris Option


-a

/usr/bin/id: list all groups.

GNU/Linux Options


-a

Ignored; for compatibility with other systems.


-Z, --context

Print the security context. SELinux only.

Mac OS X Option


-P

Print information as an /etc/passwd entry.

info

     info [options] [topics]

GNU hypertext documentation reader. Display online documentation previously built from Texinfo input. Info files are arranged in a hierarchy and can contain menus for subtopics. When entered without options, the command displays the top-level Info file (usually /usr/local/info/dir). When topics are specified, find a subtopic by choosing the first topic from the menu in the top-level Info file, the next topic from the new menu specified by the first topic, and so on. The initial display can also be controlled by the -f and -n options. If a specified topic has no Info file but does have a manpage, info displays the manpage; if there is neither, the top-level Info file is displayed.

URL: http://www.gnu.org/software/texinfo.

Options


--apropos string

Find string in the indexes of all manuals.


-d directories, --directory directories

Search directories, a colon-separated list, for info files. If this option is not specified, use the INFOPATH environment variable or the default directory (usually /usr/share/info or /usr/local/info).


--dribble file

Store each keystroke in file, which can be used in a future session with the --restore option to return to this place in info.


-f file, --file file

Display specified Info file.


--index-search string

Find the index entry string and go to the node it points to.


-n node, --node node

Display specified node in the Info file.


-o file, --output file

Copy output to file instead of displaying it at the screen.


-O, --show-options, --usage

Go to the node for command-line options.


--restore file

When starting, execute keystrokes in file.


-R, --raw-escapes

Do not remove formatting escape sequences from manpages.


--subnodes

Display subtopics.


--vi-keys

Use vi-like key bindings.

join

     join [options] file1 file2

Join the common lines of sorted file1 and sorted file2. Read standard input if file1 is -. The output contains the common field and the remainder of each line from file1 and file2. In the options below, n can be 1 or 2, referring to file1 or file2.

Common Options


-a filenum

List unpairable lines in file filenum. Use -a 1 -a 2 to list unpairable lines from both files.


-e string

Replace any empty output field with the string string.


-o n.m

Each output line contains fields specified by file number n and field number m. The common field is suppressed unless requested.


-tc

Use character c as field separator for input and output.


-v n

Print only the unpairable lines in file n. With both -v 1 and -v 2, all unpairable lines are printed.


-1 m

Join on field m of file 1. Fields start with 1.


-2 m

Join on field m of file 2. Fields start with 1.

Solaris and GNU/Linux Option


-j fieldnum

Equivalent to -1fieldnum -2fieldnum.

Solaris Options


-j1 fieldnum

Equivalent to -1fieldnum.


-j2 fieldnum

Equivalent to -2fieldnum.

GNU/Linux Option


-i, --ignore-case

Ignore case differences when comparing keys.

Examples

Assuming the following input files:

     $ cat score     olga    81      91     rene    82      92     zack    83      93     $ cat grade     olga    B       A     rene    B       A

List scores followed by grades, including unmatched lines:

     $ join -a1 score grade     olga 81 91 B A     rene 82 92 B A     zack 83 93

Pair each score with its grade:

     $ join -o 1.1 1.2 2.2 1.3 2.3 score grade     olga 81 B 91 A     rene 82 B 92 A

kill

     kill [options] IDs

Terminate one or more process IDs. You must own the process or be a privileged user. This command is similar to the kill command that is built in to the Bash, Korn, and C shells. A minus sign before an ID specifies a process group ID. (The built-in version doesn't allow process group IDs, but it does allow job IDs.)

The command kill -l prints a list of the available signal names. The list varies by system architecture; for a PC-based system, it looks like this:

     $ kill -l                                  From Bash on GNU/Linux      1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL      5) SIGTRAP      6) SIGABRT      7) SIGBUS       8) SIGFPE      9) SIGKILL     10) SIGUSR1     11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM     17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP     21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ     26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO     30) SIGPWR      31) SIGSYS      33) SIGRTMIN    34) SIGRTMIN+1     35) SIGRTMIN+2  36) SIGRTMIN+3  37) SIGRTMIN+4  38) SIGRTMIN+5     39) SIGRTMIN+6  40) SIGRTMIN+7  41) SIGRTMIN+8  42) SIGRTMIN+9     43) SIGRTMIN+10 44) SIGRTMIN+11 45) SIGRTMIN+12 46) SIGRTMIN+13     47) SIGRTMIN+14 48) SIGRTMIN+15 49) SIGRTMAX-15 50) SIGRTMAX-14     51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10     55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7  58) SIGRTMAX-6     59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2     63) SIGRTMAX-1  64) SIGRTMAX

The signals and their numbers are defined in the C <signal.h> header file. This file may include others, thus the actual location varies across systems. They are shown in the following table. (Note: you should not include these files directly; rather, always use <signal.h> in your C or C++ programs.) Look in your system's file to find the signals that apply to your system.

System

File

Solaris

/usr/include/sys/iso/signal_iso.h

GNU/Linux

/usr/include/bits/signum.h

Mac OS X

/usr/include/sys/signal.h


Common Options


-l [ status]

List the signal names. (Used by itself.) The optional status is a numeric exit value from a process killed by a signal; kill will indicate which signal it was.


-s signal

Send signal signal to the given process or process group. The signal number (from <signal.h>) or name (from kill -l). With a signal number of 9, the kill is absolute.


- signal

Send signal signal to the given process or process group. signal may be either a signal name or a signal number.

GNU/Linux Options


-a

Kill all processes of the given name (if privileges allow), not just processes with the same UID. To use this option, specify the full path (e.g., /bin/kill -a gcc).


-p

Print the process ID of the named process, but do not send it a signal. In order to use this option, specify the full path (e.g., /bin/kill -p).

ksh

     ksh [options] [arguments]

Korn shell command interpreter. See Chapter 4 for more information, including command-line options.

ld

     ld [options] objfiles

Combine several objfiles, in the specified order, into a single executable object module (a.out by default). ld is the loader and is usually invoked automatically by compiler commands such as cc.

Solaris: ld is in /usr/ccs/bin.

Options for ld vary wildly across systems. Furthermore, in the 21st century, no matter what system you work on, the loader is one of the most complicated commands. We have chosen here to document only those options that are commonly available. You will need to check your local documentation for complete information.


Options


-e symbol

Set symbol as the address of the output file's entry point.


-lx

Search a library named libx.so or libx.a (the placement of this option on the line affects when the library is searched).


-L dir

Search directory dir before standard search directories (this option must precede -l).


-o file

Send the output to file (default is a.out).


-r

Allow output to be subject to another ld. (Retain relocation information.)


-R path

Record the colon-separated list of directories in path in the object file for use by the runtime loader. Multiple instances may be supplied; the values are concatenated together.


-s

Remove (strip) symbol table and relocation entries.


-u symbol

Enter symbol in symbol table; useful when loading from an archive library. symbol must precede the library that defines it (so -u must precede -l).

ldd

     ldd [options] file

Solaris and GNU/Linux only. List dynamic dependencies: that is, list shared objects that would be loaded if file were executed. (If a valid file needs no shared objects, ldd succeeds but produces no output.) In addition, ldd's options can show unresolved symbol references that result from running file.

Options

Specify only one of these options:


-d, --data-relocs

Check references to data objects only.


-r, --function-relocs

Check references to data objects and to functions.

Solaris Options


-c

Disables the use of configuration files; see crle(1).


-e envar

Set the environment variable envar. Useful for experimenting with environment variables that affect ldd without having to change the global environment.


-f

Force checking of nonsecure executables. This option is dangerous if running as a privileged user.


-i

Print the execution order of initialization sections.


-l

Do immediate processing of any filters, to list all "filtees" and their dependencies.


-L

Enable lazy loading.


-s

Display the search path for shared object dependencies.


-u

Display unused objects. Mutually exclusive with -U.


-U

Display unused objects and dependencies. This is a superset of -u and is mutually exclusive with it.


-v

Display all dependency relationships and version requirements.

GNU/Linux Options


-v, --verbose

Print all information.


-V, --version

Display ldd's version.

less

     less [options] [filename]

less is a program for paging through files or other output. It was written in reaction to the perceived primitiveness of more (hence its name). Some commands may be preceded by a number.

URL: http://www.greenwoodsoftware.com/less.

The lesskey command configures keybindings for less. See lesskey(1) for more information on it.

Options


-[ z]num, --window=num

Set number of lines to scroll to num. Default is one screenful. A negative num sets the number to num lines less than the current number.


+[+ ]command

Run command on startup. If command is a number, jump to that line. The option ++ applies this command to each file in the command-line list.


-?, --help

Print help screen. Ignore all other options; do not page through file.


-a, --search-screen

When searching, begin after last line displayed. (Default is to search from second line displayed.)


-bbuffers, -buffers=buffers

Use buffers buffers for each file (default is 10). Buffers are 1 KB in size.


-B, --auto-buffers

Do not automatically allocate buffers for data read from a pipe. If -b specifies a number of buffers, allocate that many. If necessary, allow information from previous screens to be lost.


-c, --clear-screen

Redraw screen from top, not bottom.


-C, -CLEAR-SCREEN

Redraw screen by clearing it and then redrawing from top.


-d, --dumb

Suppress dumb-terminal error messages.


-e, --quit-at-eof

Automatically exit after reaching EOF twice.


-E, --QUIT-AT-EOF

Automatically exit after reaching EOF once.


-f, --force

Force opening of directories and devices; do not print warning when opening binaries.


-F, --quit-if-one-screen

Exit without displaying anything if first file can fit on a single screen.


-g, --hilite-search

Highlight only string found by past search command, not all matching strings.


-G, --HILITE-SEARCH

Never highlight matching search strings.


-hnum, --max-back-scroll=num

Never scroll backward more than num lines at once.


-i, --ignore-case

Make searches case-insensitive, unless the search string contains uppercase letters.


-I, --IGNORE-CASE

Make searches case-insensitive, even when the search string contains uppercase letters.


-jnum, --jump-target=num

Position target line on line num of screen. Target line can be the result of a search or a jump. Count lines beginning from 1 (top line). A negative num is counted backward from bottom of screen.


-J, --status-column

Used with -w or -W, highlight a single column on the left edge of the screen instead of the whole text of an unread line.


-kfile, --lesskey-file=file

Read file to define special key bindings.


-Kcharset

Use the specified charset.


-m, --long-prompt

Display more-like prompt, including percent of file read.


-M

Prompt more verbosely than with -m, including percentage, line number, and total lines.


-n, --line-numbers

Do not calculate line numbers. Affects -m and -M options and = and v commands (disables passing of line number to editor).


-N, --LINE-NUMBERS

Print line number before each line.


-ofile, --log-file=file

When input is from a pipe, copy output to file as well as to screen. (Prompt for overwrite authority if file exists.)


-Ofile, --LOG-FILE=file

Similar to -o, but do not prompt when overwriting file.


-ppattern, --pattern=pattern

At startup, search for first occurrence of pattern.


-P[mM= ]prompt

Set the prompt displayed by less at the bottom of each screen to prompt. The m sets the prompt invoked by the -m option, the M sets the prompt invoked by the -M option, and the = sets the prompt invoked by the = command. Special characters (described in the manpage for less), can be used to print statistics and other information in these prompts.


-q, --quiet, --silent

Disable ringing of bell on attempts to scroll past EOF or before beginning of file. Attempt to use visual bell instead.


-Q, --QUIET, --SILENT

Never ring terminal bell.


-r, --raw-control-chars

Display "raw" control characters instead of using ^x notation. This sometimes leads to display problems, which might be fixed by using -R instead.


-R, --RAW-CONTROL-CHARS

Like -r, but adjust screen to account for presence of control characters.


-s, --squeeze-blank-lines

Print successive blank lines as one line.


-S, --chop-long-lines

Cut, do not fold, long lines.


-ttag, --tag=tag

Edit file containing tag. Consult ./tags (constructed by ctags).


-Tfile, --tag-file=file

With the -t option or :t command, read file instead of ./tags.


-u, --underline-special

Treat backspaces and carriage returns as printable input.


-U, --UNDERLINE-SPECIAL

Treat backspaces and carriage returns as control characters.


-V, --version

Display version and exit.


-w, --hilite-unread

Show the line to which a movement command has skipped, phrases displayed by a search command, or the first unread line during a normal scroll by highlighting text in reverse video.


-W, --HILITE-UNREAD

Show phrases displayed by a search command, or the first unread line of any forward movement that is more than one line, by highlighting text in reverse video.


-xn, --tabs=n

Set tab stops to every n characters. Default is 8.


-X, --no-init

Do not send initialization and deinitialization strings from termcap to terminal.


-yn, --max-forw-scroll=n

Never scroll forward more than n lines at once.

Prompts

The prompt interprets certain sequences specially. Those beginning with % are always evaluated. Those beginning with ? are evaluated if certain conditions are true. Some prompts determine the position of particular lines on the screen. These sequences require that a method of determining that line be specified. See the -P option and the manpage for more information.

lex

     lex [options] [files]

Generate a lexical analysis program (named lex.yy.c) based on the regular expressions and C statements contained in one or more input files. On GNU/Linux and Mac OS X, lex is actually flex. See also yacc, bison, flex, and lex & yacc, which is listed in the Bibliography.

Options

The -e and -w options may not be available on other Unix systems where lex is the original Unix version.


-c

file's program statements are in C (default).


-e

Handle EUC (Extended Unix Code, i.e., eight-bit) characters. Mutually exclusive with -w. This gives yytext[] type unsigned char.


-n

Suppress the output summary.


-Qc

Print version information in lex.yy.c (if c = y) or suppress information (if c = n, the default).


-t

Write program to standard output, not lex.yy.c.


-v

Print a summary of machine-generated statistics.


-V

Print version information on standard error.


-w

Handle EUC (eight-bit or wider) characters. Mutually exclusive with -e. This gives yytext[] type wchar_t.

link

     link file1 file2

Create a link between two files. This is the same as the ln command, but it has no error checking because it uses the link(2) system call directly.

ln

     ln [options] existing new     ln [options] files directory

Create pseudonyms (links) for files, allowing them to be accessed by different names. In the first form, link existing to new, where new is usually a new filename. If new is an existing file, it is removed first; if new is an existing directory, a link named existing is created in that directory. In the second form, create links in directory, each link having the same name as the file specified.

Common Options


-f, --force

Force the link to occur (don't prompt for overwrite permission).


-s, --symbolic

Create a symbolic link. This lets you link across filesystems and also see the name of the link when you run ls -l. (Otherwise, you have to use find -inum to find any other names a file is linked to.)

Solaris Option


-n

/usr/bin/ln: Do not overwrite existing files.

GNU/Linux and Mac OS X Options


-i, --interactive

Prompt for permission before removing files.


-v, --verbose

Verbose mode. List files as they are processed.

GNU/Linux Options


-b, --backup[= control]

Back up any existing files. When using the long version of the option, the optional control parameter controls the kind of backup. When no control is specified, ln attempts to read the control value from the VERSION_CONTROL environment variable. Accepted values are:

none, off

Never make backups.

numbered, t

Make numbered backups.

existing, nil

Match existing backups, numbered or simple.

simple, never

Always make simple backups.



-d, -F, --directory

Allow hard links to directories. Available to privileged users.


-n, --no-dereference

Replace symbolic links to directories instead of dereferencing them. --force is useful with this option.


-S suffix, --suffix=suffix

Append suffix to files when making backups, instead of the default ~.


--target-directory=directory

Create links in the specified directory.

Mac OS X Options


-h

Do not follow symbolic links for the target file or directory. Useful with -f to replace a symbolic link that may point to a directory.


-n

Same as -h.

locale

     locale [options] [name ...]

Print locale-specific information. With no arguments, locale summarizes the current locale. Depending on the arguments, locale prints information about entire locale categories or the value of specific items within a locale. A public locale is one an application can access.

Options


-a, --all-locales

Print information about all available public locales. The POSIX locale should always be available.


-c, --category-name

Provide information about the locale category name. Useful with or without -k.


-k, --keyword-name

Print the names and values of the given locale keywords.


-m, --charmaps

Print the names of the available charmaps.

Environment variables


LANG

The default value for unset internationalization variables. If not set, the system's default value is used.


LC_ADDRESS

Postal settings, country, and language names and abbreviation.


LC_ALL

When set, overrides the values of all other internationalization variables.


LC_COLLATE

String and character sorting and comparison settings.


LC_CTYPE

Character attributes, including case conversion mappings, and categories of characters (whitespace, digit, lower, upper, punctuation, etc.).


LC_IDENTIFICATION

Information related to the current locale definition, including its title, source, revision, and contact information for its author.


LC_MEASUREMENT

Measurement units, metric or other.


LC_MESSAGES

Settings for yes/no prompts and other informative and diagnostic messages.


LC_MONETARY

Currency formats and symbols.


LC_NAME

Formats for names and honorifics.


LC_NUMERIC

Nonmonetary number formats.


LC_PAPER

Default paper sizes for printing and pagination.


LC_TELEPHONE

Telephone number formats.


LC_TIME

Date and time formats.


NLSPATH

The path for finding message catalogues used in processing messages.

Examples

Print the category name and all keywords for date and time settings:

     locale -ck LC_TIME

Print the strings used for days of the week and months of the year:

     locale day mon

locate

     locate [options] [pattern]

Search database(s) of filenames and print matches. *, ?, [, and ] are treated specially; / and . are not. Matches include all files that contain pattern unless pattern includes metacharacters, in which case locate requires an exact match.

Solaris does not provide this command. Mac OS X uses the original BSD version of this command that takes no options. For details on the GNU/Linux version of this command, see the slocate entry in the later section "Alphabetical Summary of GNU/Linux Commands."

logger

     logger [options] [messages]

Log messages to the system log. Command-line messages are logged if provided. Otherwise, messages are read and logged, line-by-line, from the file provided via -f. If no such file is given, logger reads messages from standard input.

Common Options


-f file

Read and log messages from file.


-i

Log the process ID of the logger process with each message.


-p priority

Log each message with the given priority. Priorities have the form facility.level. The default is user.notice. See syslog (3) for more information.


-t tag

Add tag to each message line.

Mac OS X and GNU/Linux Option


-s

Send the message to standard error, in addition to sending it to the system log.

GNU/Linux Options


-d

When using a specified socket with -u, use a datagram socket instead of stream socket.


-u socket

Write to socket instead of to the system log.

Example

Warn about upcoming trouble:

     logger -p user.emerg 'Incoming Klingon battleship!'

login

     login [options] [user]

Sign on and identify yourself to the system. At the beginning of each terminal session, the system prompts you for your username and, if relevant, a password. The options aren't normally used.

Bash, the Korn shell, and the C shell have their own, built-in versions of login. See Chapters 4 and 5 for more information.

Common Options


-h host [ term]

Used for remote logins via telnet to indicate the login is from host host and that the user's terminal type is term.


-p

Pass the current environment to the new login session.

Solaris Options


user

Sign on as user (instead of being prompted).


-d tty

Specify the pathname of the tty that serves as the login port.


-r host

Used for remote logins via rlogin to indicate the login is from host host.


-R repository

Use the PAM repository repository for the identity provided with -u.


-s service

Use the PAM service service. Usually not needed, but is useful, for example, with Kerberized logins.


-u identity

Provides the identity string for the user; this is usually different from the login name. In Kerberos it's the user's principal name.


-U ruser

The name of the remote person attempting a remote login. Used by in.rlogind in Kerberized mode.


var= value

When specified after the username, assign a value to one or more environment variables. PATH and SHELL can't be changed.


value

Pass values into the environment. Each value that does not contain an = is assigned to a variable of the form Ln, where n starts at 0 and increments by one.

Mac OS X and GNU/Linux Option


-f

Assume authentication has already been done. May be used only by a privileged user. The GNU/Linux login(1) manpage indicates that this option does not work well under GNU/Linux.

logname

     logname

Display your login name. The command looks the user up in the system's database of currently logged in users. It ignores both the LOGNAME and USER environment variables. See also whoami.

look

     look [options] string [file]

Look through a sorted file and print all lines that begin with string. string may be up to 256 characters long. This program is potentially faster than fgrep because it relies on the file being already sorted, and can thus do a binary search through the file, instead of reading it sequentially from beginning to end.

With no file, look searches /usr/share/lib/dict/words (the spelling dictionary) with options -df.

Common Options


-d

Use dictionary order. Only letters, digits, space, and tab are used in comparisons.


-f

Fold case; ignore case distinctions in comparisons.


-t char

Use char as the termination character, i.e., ignore all characters to the right of char.

GNU/Linux Option


-a

Use alternate dictionary /usr/share/dict/web2.

lp

     lp [options] [files]

Send files to the printer. With no arguments, prints standard input. To print standard input along with other files, specify - as one of the files.

Common Options


-c

Copy files to print spooler; if changes are made to file while it is still queued for printing, the printout is unaffected.


-d dest

Send output to destination printer named dest.


-d any

Used after -f or -S to print the request on any printer that supports the given form or character set.


-H action

Print according to the named action : hold (notify before printing), resume (resume a held request), immediate (print next; privileged users only). Mac OS X and GNU/Linux also allow restart with -i to restart a completed job.


-i IDs

Override lp options used for request IDs currently in the queue; specify new lp options after -i. For example, change the number of copies sent.


-m

Send mail after files are printed.


-n number

Specify the number of copies to print.


-o options

Set one or more printer-specific options. Standard options include:

cpi=n

Print n characters per inch. n can also be pica, elite, or compressed.

lpi=n

Print n lines per inch.

length=n

Print pages n units long; e.g., 11i (inches), 66 (lines).

nobanner

Omit banner page (separator) from request.

nofilebreak

Suppress formfeeds between files.

width=n

Print pages n units wide; e.g., 8.5i (inches), 72 (columns).

stty=list

Specify a quoted list of stty options.



-P list

Print only the page numbers specified in list.


-q n

Print request with priority level n (39 = lowest).


-s

Suppress messages.


-t title

Use title on the printout's banner page.


-w

Write a message on the user's terminal after files are printed (same as -m if user isn't logged on).

Solaris Options


-f name

Print request on preprinted form name. name references printer attributes set by the administrative command lpforms.


-p

Enable notification of completion of the print job.


-r

Don't adapt request if content isn't suitable; reject instead. (Obscure; used only with -T.)


-S name

Use the named print wheel or character set for printing.


-T content

Send request to a printer that supports content (default is simple; an administrator sets content via lpadmin -I).


-y modes

Print according to locally defined modes.

GNU/Linux and Mac OS X Options

GNU/Linux and Mac OS X use CUPS, the Common Unix Printing System. See http://www.cups.org for more information. Besides the common options, the CUPS lp accepts the following:


-E

Use encryption when connecting to the server.


-h host

Provide the print server hostname. The default is localhost or the value of $CUPS_SERVER.

Examples

Send mail after printing five copies of report :

     lp -n 5 -m report

Format and print thesis; print title too:

     nroff -ms thesis | lp - title

lpq

     lpq [options] [jobid]

Check the print spool queue for status of print jobs. For each job, display username, rank in the queue, filenames, job number, and total file size (in bytes).

On Solaris, this is the original BSD interface, in /usr/ucb/lpq; see lpq(1B) for more information. This entry documents the CUPS version, which is used on GNU/Linux and Mac OS X. See also lpr.

Options


-a

Report on all printers.


-E

Encrypt the connection to the server.


-l

Verbose mode. Print information about each file comprising a job. Use -l multiple times to increase the information provided.


-P printer

Specify which printer to query. Without this option, lpq uses the printer set in the PRINTER or other printer-related environment variables or the default system printer.


+ interval

Print the status every interval seconds until the queue is empty.

lpr

     lpr [options] [files]

Send files to the printer. On Solaris, this is the original BSD interface, in /usr/ucb/lpr; see lpr(1B) for more information. This entry documents the CUPS version, which is used on GNU/Linux and Mac OS X.

URL: http://www.cups.org. By default, CUPS makes its online documentation available via web browser at http://localhost:631/documentation.html.

Options


-# count

Print count copies (100 maximum).


-C name

Set the job name.


-E

Encrypt the connection to the server.


-J name

Same as -C.


-l

The print file is in binary form, ready to be printed. Do not apply any filtering. Equivalent to -oraw.


-o option

Set a job option. See the online documentation for more details.


-p

Supply a shaded header with the date, time, job name, and page number. Equivalent to -oprettyprint.


-P destination

Print files to the named printer.


-r

Remove the files after printing them.


-T name

Same as -C.

The original BSD and LPRng lpr options -c, -d, -f, -g, -i, -m, -n, -t, -v, and -w are not supported and produce a warning message if used.

lprm

     lprm [options] [jobid]

Remove a print job from the print spool queue. You must specify a job number or numbers, which can be obtained from lpq. Only a privileged user may remove files belonging to another user.

On Solaris, this is the original BSD interface, in /usr/ucb/lprm; see lprm(1B) for more information. This entry documents the CUPS version, which is used on GNU/Linux and Mac OS X. See also lpr.

Options


-E

Encrypt the connection to the server.


-P printer

Specify printer queue. Normally, the default printer or printer specified in the PRINTER environment variable is used.


-

Cancel all jobs.

lpstat

     lpstat [options]

Print the lp print queue status. With options that take a list argument, omitting the list produces all information for that option. list can be separated by commas or, if enclosed in double quotes, by spaces.

Common Options


-a [ list]

Show if the list of printer or class names is accepting requests.


-c [ list]

Show information about printer classes named in list.


-d

Show the default printer destination.


-l

Use after -f to describe available forms, after -p to show printer configurations, or, on Solaris, after -S to describe printers appropriate for the specified character set or print wheel.


-o [ list]

Show the status of output requests. list contains printer names, class names, or request IDs.


-p [ list]

Show the status of printers named in list.


-r

Show whether the print scheduler is on or off.


-R

Show the job's position in the print queue.


-s

Summarize the print status (shows almost everything).


-t

Show all status information (reports everything).


-u [ list]

Show request status for users on list. list can be:

user

user on local machine

all

All users on all systems

host!user

user on machine host

host!all

All users on host

all!user

user on all systems

all!all

All users on all systems



-v [ list]

Show device associated with each printer named in list.

Solaris Options


-D

Use after -p to show a brief printer description.


-f [ list]

Verify that the list of forms is known to lp.


-S [ list]

Verify the list of character sets or print wheels is known to lp.

GNU/Linux and Mac OS X Options

GNU/Linux and Mac OS X use CUPS, the Common Unix Printing System. See http://www.cups.org for more information. Besides the common options, the CUPS lpstat accepts the following:


-E

Use encryption when connecting to the server.


-h host

Provide the print server hostname. The default is localhost or the value of $CUPS_SERVER.


-W which

Show which jobs. The valid values include completed and not-completed. Use before -o and/or any printer names.

ls

     ls [options] [names]

If no names are given, list the files in the current directory. With one or more names, list files contained in a directory name or that match a file name. The options let you display a variety of information in different formats. The most useful options include -F, -R, -a, -l, and -s. Some options don't make sense together; e.g., -u and -c.

Modern versions of ls pay attention to the LC_COLLATE environment variable. Its default value, en_US, (in the United States) causes ls to sort in dictionary order (i.e., ignoring case). You may prefer to set LC_COLLATE to C to restore the traditional Unix behavior of sorting in ASCII order.


Common Options


-a, --all

List all files, including the normally hidden . files.


-A, --almost-all

Like -a, but exclude . and .. (the current and parent directories).


-b, --escape

Show nonprinting characters in octal.


-c, --time-ctime, --time=status

List files by inode modification time.


-C, --format=vertical

List files in columns (the default format, when displaying to a terminal device).


-d, --directory

List only the directory's information, not its contents. (Most useful with -l and -i.)


-f

Interpret each name as a directory (files are ignored).


-F, --classify, --indicator-style=classify

Flag filenames by appending / to directories, > to doors (Solaris only), * to executable files, | to FIFOs, @ to symbolic links, and = to sockets.


-g

Like -l, but omit owner name (show group).


-h

Produce "human-readable" output, using abbreviations for kilobyte, megabyte, and so on.


-H, --dereference-command-line

If an argument on the command line is a symbolic link, list the file or directory referenced by a symbolic link rather than the link itself.


-i, --inode

List the inode number for each file.


-l, --format=long, --format=verbose

Long format listing (includes permissions, owner, size, modification time, etc.).


-L

List the file or directory referenced by a symbolic link rather than the link itself.


-m, --format=commas

Merge the list into a comma-separated series of names.


-n, --numeric-uid-gid

Like -l, but use user ID and group ID numbers instead of owner and group names.


-p, --filetype, --indicator-style=file-type

Mark directories by appending / to them. GNU/Linux also appends | to FIFOs, @ to symbolic links, and = to sockets. (Almost, but not quite, the same as -F.)


-q, --hide-control-chars

Show nonprinting characters as ?.


-r, --reverse

List files in reverse order (by name or by time).


-R, --recursive

Recursively list subdirectories as well as current directory.


-s, --size

Print sizes of the files in blocks.


-t, --sort=time

List files according to modification time (newest first).


-u, --time=atime, --time=access, --time=use

List files according to the file access time.


-x, --format=across, --format=horizontal

List files in rows going across the screen.


-1, --format=single-column

Print one entry per line of output.

Solaris and GNU/Linux Option


-o

Like -l, but omit group name (show owner).

Solaris Options


-e

Like -l, but use the same format for times regardless of age: mmm dd hhh:mm:ss yyyy.


-E

Like -l, but use the ISO 8601 format for times regardless of age: yyyy-mm-dd hh:mm:ss.nnnnnnnnn.


-@

Like -l, but extended attribute information supersedes ACL information. ls places an @ after the permission bits for files with extended attributes.

GNU/Linux Options


--author

Print the author of each file. On GNU/Hurd systems, the author is different than the owner. On all other systems, this prints the file's owner.


--block-size=size

Use blocks of size bytes.


-B, --ignore-backups

Do not list files ending in ~ unless given as arguments.


--color[= when]

Colorize the names of files depending on the type of file. Accepted values for when are never, always, or auto.


--dereference-command-line-symlink-to-dir

Follow command-line argument symbolic links that point to directories.


-D, --dired

List in a format suitable for Emacs dired mode.


--full-time

List times in full, rather than using the standard abbreviations.


-G, --no-group

In long format, do not display group name.


--indicator-style=style

Add trailing indicators to filenames according to style. Possible values are none, classify (same as -F), and file-type (same as -p). Default is none.


-Ipattern, --ignore pattern

Do not list files whose names match the shell pattern pattern unless they are given on the command line.


-k, --kilobytes

If file sizes are being listed, print them in kilobytes. This option overrides the environment variable POSIXLY_CORRECT.


--lcontext

Display the full security context. Implies -l. SELinux only.


-N, --literal

Display special graphic characters that appear in filenames.


--quoting-style=style

Use the style quoting style. Possible values are: c, escape, literal, locale, shell, and shell-always.


-Q, --quote-name

Quote filenames with "; quote nongraphic characters.


--scontext

Display only the filename and the security context. SELinux only.


--show-control-chars

Show nonprinting characters verbatim (default for printing to a file).


--si

Similar to -h, but uses powers of 1000 instead of 1024.


--sort=criteria

Sort by the given criteria. Possible values and their corresponding options are: access (-u), atime (-u), extension (-X), none (-U), size (-S), status (-c), time (-t), use (-u), and version (-v).


-S, --sort=size

Sort by file size, largest to smallest.


--time=filetime

Show the given time attribute of the file instead of the modification time. Allowed values are: atime, access, use, ctime, and status. The time attribute is used for sorting with --sort=time.


--time-style=style

Format times according to the given style. If style is preceded by posix-, then the style is used only if not in the POSIX locale. Allowed values are: full-iso, iso, locale, long-iso, and +format.

For +format, the format is interpreted as for date (see date). Two formats may be provided separated by a newline. In this case, the first one applies to nonrecent files, and the second one applies to recent files.


-T ncols, --tabsize=ncols

Set tab stops at ncols columns.


-U, --sort=none

Do not sort files.


-v, --sort=version

Interpret the digits in names such as file.6 and file.6.1 as versions, and order filenames by version.


-w n, --width=n

Format output to fit n columns.


-X, --sort=extension

Sort by file extension, then by filename.


-Z, --context

Display the security context so that it will fit on the screen. The information given is the mode, user, group, security context, and filename. SELinux only.

Mac OS X Options


-B

Print nonprintable characters as an octal escape: \nnn.


-e

Print the Access Control List (ACL) of the file, if any.


-G

Enable colorized output.


-k

For use with -s; print file sizes in kilobytes, not blocks. Overrides the BLOCKSIZE environment variable.


-o

Include the file flags in the long format listing (-l).


-P

Cancel the -H and -L options, causing ls to list information about symbolic links, not the files they point to.


-S

Sort files by their size.


-T

Use with -l. Print complete time information, including month, day, hour, minute, second, and year.


-w

Print nonprintable characters verbatim. This is the default if the output is not a terminal.


-W

Display whiteout entries when scanning directories.


-v

Print nongraphic characters verbatim. This is the default if the output is not a terminal.

Examples

List all files in the current directory and their sizes; use multiple columns and mark special files:

     ls -asCF

List the status of directories /bin and /etc :

     ls -ld /bin /etc

List C source files in the current directory, the oldest first:

     ls -rt *.c

Count the files in the current directory:

     ls | wc -l

m4

     m4 [options] [files]

General purpose macro processor. On Solaris, m4 is found in /usr/ccs/bin and is the original Unix version. GNU/Linux and Mac OS X use the GNU version of m4. (On Solaris, GNU m4 is in /usr/sfw/bin/gm4.)

URL: http://www.gnu.org/software/m4.

Common Options


-Bn

Set push-back and argument collection buffers to n (default is 4096). Ignored by GNU m4.


-Dname[= value], --define=name[= value]

Define name as value or, if value is not specified, define name as null.


-e, --interactive

Operate interactively, ignoring interrupts.


-Hn, --hashsize=n

Set symbol table hash array size to n (default is 199 on Solaris, 509 for GNU m4).


-s, --synclines

Enable line-sync output (#line directives) for the C preprocessor.


-Sn

Set call stack size to n (default is 100 slots). Ignored by GNU m4.


-Tn

Set token buffer size to n (default is 512 bytes). Ignored by GNU m4.


-Uname, --undefine=name

Undefine name.

GNU m4 Options


-d [ flags], --debug[= flags]

Specify flag-level debugging. Default is flags aeq.


-E, --fatal-warnings

Consider all warnings to be fatal, and exit after the first of them.


-F file, --freeze-state=file

Record m4's frozen state in file for later reloading.


-G, --traditional

Behave like traditional m4, ignoring GNU extensions.


-I directory, --include=directory

Search directory for include files.


-l n, --arglength=n

Specify the length of debugging output.


-L n, --nesting-limit=n

Limit the textual nesting of macros calls to n. The default is 250. Useful for some machine-generated input.


-o file, --error-output=file

Place output in file. Despite the option's name, print error messages on standard error.


-P, --prefix-built-ins

Prepend m4_ to all built-in macro names.


-Q, --quiet, --silent

Suppress warning messages.


-R file, --reload-state=file

Load state from file before starting execution.


-t name, --trace=name

Insert name into symbol table as undefined. Trace macro from the point it is defined.

mail

     mail [options] [users]

Read mail (if no users listed), or send mail to other users. Type ? for a summary of commands. Esoteric debugging options exist (not listed) for system administrators. See also mailx, and vacation in the later section "Alphabetical Summary of Solaris Commands."

This is the original V7 Unix mail program. On Mac OS X and GNU/Linux, mail is really mailx. See mailx.


Options for Sending Mail


-m type

Print a "Message-type:" line at the heading of the letter, followed by type of message.


-t

Print a "To:" line at the heading of the letter, showing the names of the recipients.


-w

Force mail to be sent to remote users without waiting for remote transfer program to complete.

Options for Reading Mail


-e

Test for the existence of mail without printing it. Exit status is 0 if mail exists; otherwise 1.


-f file

Read mail from alternate mailbox file.


-h

Display a window of messages rather than the latest message.


-p

Print all messages without pausing.


-P

Print messages with all header lines displayed.


-q

Terminate on an interrupt.


-r

Print oldest messages first.

mailx

     mailx [options] [users]     Mail [options] [users]

Read mail, or send mail to other users. For a summary of commands, type ? in command mode (e.g., when reading mail) or ~? in input mode (e.g., when sending mail). The start-up file .mailrc in the user's home directory is useful for setting display variables and for defining alias lists.

Version Names

The original V7 Unix mail program provided a very spartan interactive user interface.[*] This inspired the creation of Berkeley Mail, a more capable mail-reading program for BSD Unix. Not surprisingly, and because Unix systems distinguish between uppercase and lowercase, the program was named Mail, and it lived in the /usr/ucb directory. When the System V developers imported Berkeley Mail, they renamed it mailx, to avoid the case-distinction problem. By that name the command was standardized in POSIX. Today, just to keep life interesting, different systems offer the program under multiple names and locations, as follows:

[*] This program survives on commercial Unix systems as /bin/mail; its primary use these days is by Mail Transport Agents, such as Sendmail, for physical delivery of mail into a user's mailbox. Even long-time Unix veterans do not use it interactively.


Solaris

The program is in /usr/bin/mailx. /usr/ucb/mail and /usr/ucb/Mail are symbolic links to it.


GNU/Linux

The program is in /bin/mail. /usr/bin/Mail is a symbolic link to it. There is no mailx command.


Mac OS X

The program is in /usr/bin/mailx. /usr/bin/mail is a hard link to it. Because the Mac OS X HFS filesystem ignores case, /usr/bin/Mail is the same as /usr/bin/mail (i.e., typing Mail at a shell prompt runs /usr/bin/mail).

Common Options


-b address

Send blind carbon copies to address. Quote the list if there are multiple recipients.


-c address

Send carbon copies to address. Quote the list if there are multiple recipients.


-d

Set debugging.


-f [ file]

Read mail in alternate file (default is mbox).


-i

Ignore interrupts (useful on modems); same as mailx option ignore.


-I

Use with -f when displaying saved news articles; newsgroup and article ID headers are included.


-n

Do not read the system startup mailx.rc or Mail.rc file(s).


-N

Don't print mail header summary.


-s sub

Place string sub in the Subject: header field. sub must be quoted if it contains whitespace.


-u user

Read user's mail.


-v

Verbose mode; displays delivery details.

Solaris and Mac OS X Options


-e

Test for the existence of mail without printing it. Exit status is 0 if mail exists; otherwise 1.


-F

Store message in a file named after the first recipient.


-H

Print mail header summary only.

Solaris Options


-B

Do not buffer standard input or standard output.


-H

Print mail header summary only.


-r address

Specify a return address for mail you send.


-t

Use To:, Cc:, and Bcc: headers in the input to specify recipients instead of command-line arguments.


-T file

Record message IDs and article IDs (of news articles) in file.


-U

Convert uucp-type addresses to Internet format.


-V

Print version number of mailx and exit.


-~

Process tilde escapes, even if not reading from a terminal.

Mac OS X Option


-E

Do not send messages with an empty body. Useful for receiving output from cron scripts.

make

     make [options] [targets]

Update one or more targets according to dependency instructions in a description file in the current directory. By default, this file is called makefile or Makefile.

On Solaris make is found in /usr/ccs/bin, and GNU make is in /usr/sfw/bin/gmake. GNU/Linux and Mac OS X use GNU make. See Chapter 16 for more information on GNU make, including Internet download information. See also Managing Projects with GNU make, listed in the Bibliography.

man

     man [options] [[section] subjects]

Display information from the online reference manual. Each subject is usually the name of a command from Section 1 of the online manual, unless you specify an optional section from 1 to 8. If you don't specify a subject, you must supply either a keyword (for -k) or a file (for -f). No options except -M can be used with -k or -f. The MANPATH environment variable defines the directories in which man searches for information (default is /usr/share/man). PAGER defines how output is sent to the screen. Note: in Solaris, section must be preceded by -s. GNU/Linux and Mac OS X use the same man program.

Options


-a

Show all pages matching subject.


-d

Debug; evaluate the man command and print debugging information, but don't execute.


-f files

Display a one-line summary of one or more reference files. Same as whatis.


-k keywords

Display any header line that contains one of the specified keywords. Same as apropos.


-M path

Search for online descriptions in directory path instead of default directory. -M overrides MANPATH.


-t

Format the manpages with troff.

Solaris Options


-

Pipe output through cat instead of more -s.


-F

Search MANPATH directories, not windex database.


-l

Like -a, but list only the pages.


-r

Reformat but don't display manpage. Same as man - -t.


-s section

Specify the section of the manpage to search in. Required for anything that isn't a command.


-T mac

Display information using macro package mac instead of tmac.an (the man macros).

GNU/Linux and Mac OS X Options


-c

Reformat the source file, even if a preformatted manual page exists.


-C file

Use an alternate configuration file.


-D

Like -d, but also print the manual page.


-F

Format only, do not display the formatted pages.


-h, --help

Print a command-line summary and exit.


-K

Search for a string in all manpages.


-m system

Search an alternate set of manpages based on the system name.


-p letters

Specify the order in which to run various troff preprocessors based on letters. The letters and their program are:

e: eqn or neqn

p: pic

t: tbl

g: grap

r: refer

v: vgrind



-P program

Use program as the pager.


-w, --path

Print the location of the manpage that would be displayed. With no argument, print the list of directories to be searched.


-W

Like -w, but print names one per line.

Examples

Save documentation on the mv command (strip overstruck characters):

     man mv | sed 's/.^H//g' > mv.txt

Display commands related to linking and compiling:

     man -k link compile | more

Display a summary of all intro files:

     man -f intro

Look up the intro page from Section 3M (the math library):

     man 3m intro                   In most systems     man -s 3m intro                In Solaris

mesg

     mesg [options]

Change the ability of other users to use talk, or to send write messages to your terminal. With no options, display the permission status.

Options


n

Forbid write messages.


y

Allow write messages (the default).

Solaris allows you to supply a leading - (i.e., -n, -y).

mkdir

     mkdir [options] directories

Create one or more directories. You must have write permission in the parent directory in order to create a directory. See also rmdir.

Common Options


-m, --mode mode

Set the access mode for new directories.


-p, --parents

Create intervening parent directories if they don't exist.

GNU/Linux Options


-v, --verbose

Print directory names as they are created.


-Z context, --context context

Set the security context. SELinux only.

Mac OS X Option


-v

Print directory names as they are created.

Examples

Create a read/execute-only directory named personal :

     mkdir -m 555 personal

The following sequence:

     mkdir work; cd work     mkdir junk; cd junk     mkdir questions; cd ../..

could be accomplished by typing this:

     mkdir -p work/junk/questions

mkisofs

     mkisofs [options] -o file pathspecs

Solaris and GNU/Linux only. Generate an ISO9660/Joliet/HFS filesystem for writing to a CD with a utility such as cdrecord. (HFS is the native Macintosh Hierarchical File System.) mkisofs takes a snapshot of a directory tree and generates a binary image that corresponds to an ISO9660 or HFS filesystem when it is written to a block device. Each specified pathspec describes the path of a directory tree to be copied into the ISO9660 filesystem; if multiple paths are specified, the files in all the paths are merged to form the image.

Options


-abstract file

Specify the abstract filename. Overrides an ABST=file entry in .mkisofsrc.


-allow-leading-dots, -ldots

Allow ISO9660 filenames to begin with a period.


-allow-lowercase

Allow ISO9660 filenames to be lowercase. Violates the ISO9660 standard.


-allow-multidot

Allow more than one dot in ISO9660 filenames. Violates the ISO9660 standard.


-A id, -appid id

Specify a text string id that describes the application to be written into the volume header.


-b image, -eltorito-boot image

Specify the path and filename of the boot image to be used for making a bootable CD based on the El Torito specification.


-B sun-images, -sparc-boot sun-images

Specify a comma-separated list of boot images needed to make a bootable CD for a Sun Sparc system.


-biblio file

Specify bibliographic filename. Overrides a BIBLIO=file entry in .mkisofsrc.


-boot-info-table

Specify that a 56-byte table with information on the CD layout is to be patched in at offset 8 of the boot file. If specified, the table is patched into the source boot file, so make a copy if the file isn't recreatable.


-boot-load-seg addr

Specify the load segment address of the boot image for a no-emulation El Torito CD.


-boot-load-size size

Specify the number of virtual 512-byte sectors to load in no-emulation mode. The default is to load the entire boot file. The number may need to be a multiple of four to prevent problems with some BIOSes.


-c catalog, --eltorito-catalog catalog

Specify the path, relative to the source pathspec, and the filename of the boot catalog for an El Torito bootable CD. Required for making a bootable CD.


-cache-inodes, -no-cache-inodes

Cache [do not cache] inode and device numbers to find hard links to files. The default on Linux is to cache. Use -no-cache-inodes for filesystems that do not have unique inode numbers.


-check-oldnames

Check all filenames imported from old sessions for mkisofs compliance with ISO9660 file-naming rules. If not specified, check only those files with names longer than 31 characters.


-check-session file

Check all old sessions for mkisofs compliance with ISO9660 file-naming rules. This option is the equivalent of:

-M file -C 0,0 -check-oldnames

where file is the pathname or SCSI device specifier that would be specified with -M.


-chrp-boot

Add a CHRP boot header.


-copyright file

Specify the name of the file that contains the copyright information. Overrides a COPY=file entry in .mkisofsrc.


-C last-start,next-start


-cdrecord-params last-start,next-start

Required for creating a CDExtra or a second or higher-level session for a multisession CD. last-start is the first sector number in the last session on the disk, and next-start is the first sector number for the new session. Use the command:

cdrecord -msinfo

to get the values. Use -C with -M to create an image that is a continuation of the previous session; without -M, create an image for a second session on a CDExtra (a multisession CD with audio data in the first session and an ISO9660 filesystem image in the second).


-d, -omit-period

Omit trailing period from files that do not have one. Violates the ISO9660 standard, but works on many systems.


-debug

Enable debugging.


-dev device

For use with -C and -M, device is the device name from which to read the previous session of a multisession CD.


-D, -disable-deep-relocation

Do not use deep directory relocation. Violates the ISO9660 standard, but works on many systems.


-dir-mode mode

Specify the mode for directories used to create the image. Automatically enables the Rock Ridge extensions.


-dvd-video

Generate a UDF filesystem compliant with DVD videos.


-eltorito-alt-boot

Start with a new set of El Torito boot parameters. Allows putting more than one El Torito boot image on a CD (maximum is 63).


-exclude-list file

Check filenames against the globs contained in the specified file and exclude any that match.


-f, -follow-links

Follow symbolic links when generating the filesystem.


-file-mode mode

Specify the mode for files used to create the image. Automatically enables the Rock Ridge extensions.


-force-rr

Do not use automatic Rock Ridge detection for the previous session.


-G image, --generic-boot image

Specify the path and filename of the generic boot image for making a generic bootable CD.


-gid gid

Set the group ID to gid for the source files. Automatically enables the Rock Ridge extensions.


-graft-points

Allow the use of graft points for filenames, which permits paths to be grafted at locations other than the root directory. -graft-points checks all filenames for graft points and divides the filename at the first unescaped equals sign (=).


-gui

Switch the behavior for a GUI. Currently, the only effect is to make the output more verbose.


-hard-disk-boot

Specify that the boot image to be used to create an El Torito bootable CD is a hard disk image and must begin with a master boot record containing a single partition.


-help

Print a help message.


-hidden glob

Set the hidden (existence) ISO9660 directory attribute for paths or filenames matching the shell-style pattern glob. To match a directory, the path must not end with a trailing /.


-hidden-list file

Specify a file containing a list of globs that are to be hidden with -hidden.


-hide glob

Find paths or files that match the shell-style pattern glob and hide them from being seen on the ISO9660 or Rock Ridge directory. The files are still included in the image file. If the pattern matches a directory, the contents of the directory are hidden. To match a directory, the path must not end with a trailing /. Use with the -hide-joliet option.


-hide-joliet glob

Hide paths or files that match the shell-style pattern glob so they will not be seen in the Joliet directory. If the pattern matches a directory, the contents of the directory are hidden. To match a directory, the path must not end with a trailing /. Should be used with -hide.


-hide-joliet-list file

Specify a file with a list of globs to be hidden with -hide-joliet.


-hide-joliet-trans-tbl

Hide the TRANS.TBL files from the Joliet tree.


-hide-list file

Specify a file containing a list of globs to be hidden with -hide.


-hide-rr-moved

Rename the directory RR_MOVED to .rr_moved to hide it as much as possible from the Rock Ridge directory tree. Use the -D option to omit the file entirely.


-input-charset charset

Specify the character set for characters used in local filenames. Specify help in place of a charset for a list of valid character sets.


-iso-level level

Set the ISO9660 conformance level. Possible values are:

1

Filenames are restricted to 8.3 characters and files may have only one section.

2

Files may have only one section.

3

No restrictions.



-jcharset charset

The equivalent of -input-charset -J.


-J, -joliet

Generate Joliet directory records in addition to regular ISO9660 filenames.


-joliet-long

Allow Joliet filenames to be up to 103 Unicode characters. This breaks the Joliet specification but apparently works.


-l, -full-iso9660-filenames

Allow full 31-character filenames instead of restricting them to the MS-DOS-compatible 8.3 format.


-log-file file

Send all messages to the specified log file.


-m glob, -exclude glob

Exclude files matching the shell-style pattern glob.


-max-iso9660-filenames

Allow up to 37 characters in ISO9660 filenames. Forces -N. Violates the ISO9660 standard.


-M path, -prev-session path

Specify the path to an existing ISO9660 image to be merged. path can also be a SCSI device specified in the same syntax as cdrecord's dev= parameter. May be used only with -C.


-new-dir-mode mode

Specify the mode to use for new directories in the image. The default is 0555.


-nobak, -no-bak

Do not include backup files on the ISO9660 filesystem.


-no-boot

Mark the El Torito CD to be created as not bootable.


-no-emul-boot

Specify that the boot image for creating an El Torito bootable CD is a no-emulation image.


-no-iso-translate

Do not translate the # and ~ characters. Violates the ISO9660 standard.


-no-rr

Do not use Rock Ridge attributes from previous sessions.


-no-split-symlink-components

Do not split symlink components.


-no-split-symlink-fields

Do not split symlink fields.


-N, -omit-version-number

Omit version numbers from ISO9660 filenames. Violates the ISO9660 standard. Use with caution.


-old-root dir

Specify dir as the root used with -root for a previous session. Used for doing incremental backups.


-output-charset charset

Specify the output character set for Rock Ridge filenames. The default is the input character set.


-p prepid, -preparer prepid

Specify a text string of up to 128 characters describing the preparer of the CD. Overrides a PREP= parameter set in the file .mkisofsrc.


-publisher pubid

Specify a text string of up to 128 characters describing the publisher of the CD to be written to the volume header. Overrides a PUBL= parameter set in .mkisofsrc.


-pad, -no-pad

Pad [do not pad] the ISO9660 filesystem by 16 sectors (32KB). If the resulting size is not a multiple of 16 sectors, add sectors until it is. The default is -pad.


-path-list file

Specify a file that contains a list of pathspec directories and filenames to add to the ISO9660 filesystem. Note that at least one pathspec must be given on the command line.


-print-size

Print estimated filesystem size and exit.


-quiet

Run in quiet mode; do not display progress output.


-r, -rational-rock

Like -R, but set UID and GID to zero, set all file read bits to on, and turn off all file write bits. If any execute bit is set for a file, set all execute bits; if any search bit is set for a directory, set all search bits; if any special mode bits are set, clear them.


-relaxed-filenames

Allow ISO9660 filenames to include seven-digit ASCII characters except lowercase characters. Violates the ISO9660 standard.


-root dir

Makes dir be the root of the filesystem on the image. Similar to -graft-points.


-R, -rock

Generate SUSP (System Use Sharing Protocol) and Rock Ridge records using the Rock Ridge protocol.


-sort file

Sort file locations according to the rules in the specified file, which contains pairs of filenames and weights, with one space or tab between them. A higher weight puts the file closer to the beginning of the media.


-sparc-label text

Set the Sun disk label to text.


-split-output

Split the output into files approximately one gigabyte in size. Useful for creating DVDs on operating systems that don't support large files.


-stream-file-name name

Reserved for future use.


-stream-media-size size

Operate in streaming mode, with size as the media size in sectors. This creates a simple ISO9660 archive named STREAM.IMG. See the manpage for details.


-sunx86-boot files

Use files to create a Solaris x86 bootable CD.


-sunx86-label text

Set the System V Release 4 disk label on a Sun x86 CD to text.


-sysid id

Specify the system ID. Overrides a SYSI= parameter set in the file .mkisofsrc.


-table-name table

Use table as the translation table name instead of TRANS.TBL. Implies -T. For a multisession image, the table name must be the same as the previous session.


-T, -translation-table

Generate the file TRANS.TBL in each directory for establishing the correct filenames on non-Rock Ridge-capable systems.


-ucs-level num

Set the Unicode conformance level to the specified number, which can be between 1 and 3 (default is 3).


-udf

Produce a UDF filesystem.


-uid uid

Set the user ID to uid for the source files. Automatically enables the Rock Ridge extensions.


-use-fileversion level

Use file version numbers from the filesystem. The version number is a string from 1 to 32767. The default is to set a version of 1.


-U, -untranslated-filenames

Allow untranslated filenames. Violates the ISO9660 standard. Forces the options -d, -l, -N, -relaxed-filenames, -allow-lowercase, -allow-multidot, and -allow-leading-dots. Use with extreme caution.


-v, -verbose

Run in verbose mode. Specify twice to run even more verbosely.


-version

Print version information.


-volset id

Specify the volume set ID. Overrides a VOLS= parameter specified in .mkisofsrc.


-volset-seqno num

Set the volume set sequence number to num. Must be specified after -volset-size.


-volset-size num

Set the volume set size (the number of CDs in a set) to num. Must be specified before -volset-seqno.


-V volid, -volid volid

Specify the volume ID (volume name or label) to be written to the master block. Overrides a VOLI= parameter specified in the file .mkisofsrc.


-x path, -old-exclude path

Exclude path from being written to the CD, where path is the complete pathname derived from the concatenation of the pathname from the command line and the path relative to this directory. May be specified more than once to exclude multiple paths.


-z, -transparent-compression

Generate RRIP records for transparent compression. Violates the ISO9660 standard. Must be used with -r or -R. Such CDs are only transparently readable under GNU/Linux.

HFS options


-auto file

Set file as the Autostart file to make the HFS CD use the QuickTime 2.0 Autostart feature. file must be the name of an application or document at the top level of the CD and must be less than 12 characters long.


-boot-hfs-file file

Install file as the driver file that may make the CD bootable on a Macintosh.


-cluster-size size

Specify the size in bytes of a cluster or allocation units of PC Exchange files. Implies the use of --exchange.


-g, -apple

Create an ISO9660 CD with Apple's extensions.


-h, -hfs

Create a hybrid ISO9660/HFS CD. Use with -map, -magic, and/or the various HFS options.


-hfs-bless folder

"Bless" the specified directory (folder), specified as the full pathname to mkisofs. This is usually the System Folder and is used in creating HFS bootable CDs. The pathname must be in quotes if it contains spaces.


-hfs-creator creator

Set the four-character default creator for all files.


-hfs-parms parameters

Override certain HFS filesystem parameters. The manpage points you to a file in the source code for more details.


-hfs-type type

Set the four-character default type for all files.


-hfs-unlock

Leave the HFS volume unlocked so other applications can modify it. The default is to lock the volume.


-hfs-volid id

Specify the volume name for the HFS partition. This name is assigned to the CD on a Macintosh and replaces the ID set with the -V option.


-hide-hfs glob

Hide files or directories matching the shell-style pattern glob from the HFS volume, although they still exist in the ISO9660 and/or Joliet directory. May be specified multiple times.


-hide-hfs-list file

The specified file contains a list of globs to be hidden.


-icon-position

Use the icon position from the HFS file. This is an experimental option.


-input-hfs-charset charset

Specify the input character set used for HFS filenames when used with the -mac-name option. The default is cp10000 (Mac Roman).


-mac-name

Use the HFS filename as the starting point for the ISO9660, Joliet, and Rock Ridge filenames.


-magic file

Use the specified magic file to set a file's creator and type information based on the file's magic number, which is usually the first few bytes of the file. The magic file contains entries consisting of four tab-separated columns specifying the byte offset, type, test, and a message.


-map file

Use the specified mapping file to set a file's creator and type information based on the filename extension. Only files that are not known Apple or Unix file types need to be mapped. The mapping file consists of five-column entries specifying the extension, file translation, creator, type, and a comment. Creator and type are both four-letter strings.


-no-desktop

Do not create empty Desktop files. The default is to create such files.


-output-hfs-charset charset

Specify the output character set used for HFS filenames. Defaults to the input character set.


-part

Generate an HFS partition table. The default is not to generate the table.


-prep-boot file

PReP boot file. Up to four may be provided. Experimental option.


-probe

Search the contents of files for known Apple or Unix file types.


-root-info file

Set the information for the root folder from file. Experimental option.


--format

Look for Macintosh files of the specified file format type. The valid formats are cap (Apple/Unix File System (AUFS) CAP files), dave, double, ethershare, exchange, macbin, netatalk, osx-double, osx-hfs, sfm, sgi, single, ushare, and xinet.

mktemp

     mktemp [options] template

Generate a unique temporary filename for use in a script. The filename is based on the specified template, which may be any filename with at least six Xs appended (e.g., /tmp/mytemp.XXXXXX). mktemp replaces the Xs with the current process number and/or a unique letter combination. The file is created with mode 0600 (unless -u is specified) and the filename is written to standard output.

Common Options


-d

Make a directory, not a file.


-q

Fail silently in case of error. Useful to prevent error output from being sent to standard error.


-u

Operate in "unsafe" mode and unlink the temporary file before mktemp exits. Use of this option is not recommended.

Solaris and GNU/Linux Options


-p prefix

Use prefix as the directory for the temporary filename. The TMPDIR environment variable overrides this option. Implies -t.


-t

Create a path in a temporary directory. The directory name is the first of: the TMPDIR environment variable; the value of prefix given to -p; or /tmp.

GNU/Linux Option


-V

Print version information and exit.

Mac OS X Option


-t [ prefix]

Like Solaris -p, except that the prefix is optional.

more

     more [options] [files]

Display the named files on a terminal, one screenful at a time. After each screen is displayed, press the ENTER key to display the next line or press the spacebar to display the next screenful. Press h for help with additional commands, q to quit, / to search, or :n to go to the next file. more can also be invoked using the name page.

The Mac OS X more is a hard link to less; see less for more information.


Common Options


-c

Page through the file by clearing the screen instead of scrolling. This is often faster and is much easier to read.


-d

Display the prompt Press space to continue, 'q' to quit.


-f

Count logical rather than screen lines. Useful when long lines wrap past the width of the screen.


-l

Ignore formfeed (^L) characters.


-s

Squeeze; display multiple blank lines as one.


-u

Suppress underline characters and backspace (^H).


-n

Use n lines for each "window" (default is a full screen).


+ num

Begin displaying at line number num.


+/ pattern

Begin displaying two lines before pattern.

Solaris /usr/xpg4/bin/more Options


-e

Exit after writing the last line of the last file, instead of prompting.


-i

Ignore case when searching.


-n n

Use n lines for each "window" (default is a full screen).


-p command, + command

Execute more command command before showing each file.


-t tagstring

Display the screenful of the file containing the tag tagstring as defined by ctags. Processed before -p if both are given.

Solaris /usr/bin/more Options


-r

Force display of control characters, in the form ^x.


-w

Wait for a user keystroke before exiting.

GNU/Linux Option


-p

Do not scroll; clear the screen and then show the text.

Examples

Page through file in "clear" mode, and display prompts:

     more -cd file

Format doc to the screen, removing underlines:

     nroff doc | more -u

View the manpage for the grep command; begin near the word "BUGS" and compress extra whitespace:

     man grep | more +/BUGS -s

mount

     mount [options] [arguments]

Mount a filesystem. This command is very system-specific. See the mount entries in the sections for each operating system.

msgfmt

     msgfmt [options] pofiles

Solaris and GNU/Linux only. msgfmt translates "portable object files" (.po files) into loadable message files that can be used by a running application via the gettext (3C) and dgettext (3C) library functions.

Portable object files are created using xgettext from the original C source code files. A translator then edits the .po file, providing translations of each string (or "message") in the source program. The format is described in the msgfmt (1) manpage.

Once compiled by msgfmt, the running program uses the translations for its output when the locale is set up appropriately.

The Solaris version of this command has picked up some features from the GNU version; see gettext for more discussion of this fact and for a URL reference. The Solaris version can create both Solaris format output files and GNU format output files.

Common Options


-D dir, --directory=dir

Add dir to the list of directories searched for input files.


-f, --use-fuzzy

Place fuzzy entries in the output.


-o file, --output=file

Place the output in file. This option ignores domain directives and duplicate msgids.


--strict

Enable strict Uniforum compliance: append the .mo suffix if not already present. The Solaris version ignores this option for Solaris output format files.


-v, --verbose

Be verbose. Duplicate message identifiers are listed, but message strings are not redefined.

Solaris Options


-g

Generate GNU format output files. Mutually exclusive with -s.


-s

Generate Solaris format output files. Mutually exclusive with -g.

GNU/Linux Options

The GNU gettext package continues to acquire features over time. The following list may thus be incomplete; check msgfmt(1) for the full story.


-a count, --alignment=count

Align strings to count bytes (default is one).


-c, --check

Do all of --check-domain, --check-format, and --check-header.


--check-accelerators[= char]

Verify translation of menu-item keyboard-accelerator strings. Such strings are assumed to use & as the "marker" for accelerator keys; this option verifies that the translation only has one & character. With char, use that character instead of &.


--check-domain

Check for conflicts between the -o option and domain directives.


--check-format

Check language-dependent format strings.


--check-header

Check for the presence of the header entry, and verify its contents.


--csharp

C# mode: Create a .NET .dll file.


--csharp-resources

Create a .NET .resources file.


--C, --check-compatibility

Be compatible with the X/Open msgfmt. This produces errors if any GNU extensions are used.


-d dir

Place generated files for C#, Java and Tcl underneath dir.


-h, --help

Print a command-line summary and exit.


-j, --java

Java mode: create a Java ResourceBundle class.


--java2

Like -j, but assume JDK 1.2 or higher.


-l locale, --locale=locale

Specify the locale for C#, Java and Tcl modes.


--no-hash

Do not include the hash table in the binary file.


-P, --properties-input

The input files use Java .properties syntax.


--qt

Qt mode: create a Qt .qm file.


-r resource, --resource=resource

Specify the resource name for C# and Java modes.


--statistics

Print translation statistics.


--stringtable-input

The input files use NeXTstep/GNUstep .strings syntax.


--tcl

Tcl mode: create a tcl/msgcat .msg file.


-V, --version

Print version information and exit.

mv

     mv [options] sources target

Basic command to move files and directories around on the system or to rename them. mv works as the following table shows.

Source

Target

Result

File

name

Rename file as name.

File

Existing file

Overwrite existing file with source file.

Directory

name

Rename directory as name.

Directory

Existing directory

Move directory to be a subdirectory of existing directory.

One or more files

Existing directory

Move files to directory.


Common Options


--

Use this when one of the names begins with a -. For compatibility with old programs, a plain - also works.


-f, --force

Force the move, even if target file exists; suppress messages about restricted access modes.


-i, --interactive

Inquire; prompt for a y (yes) response before overwriting an existing target.

GNU/Linux Options


-b, --backup[= control]

Back up any existing files. When using the long version of the option, the optional control parameter controls the kind of backup. When no control is specified, mv attempts to read the control value from the VERSION_CONTROL environment variable. Accepted values are:

none, off

Never make backups.

numbered, t

Make numbered backups.

existing, nil

Match existing backups, numbered or simple.

simple, never

Always make simple backups.



--reply=type

Set the default behavior that is used for overwriting existing files. --replay=yes is the same as --force. --replay=query is the same as --interactive. --replay=no skips existing files.


--strip-trailing-slashes

Removes trailing slashes from each source argument. This is needed on many systems for symbolic links that point to directories; on POSIX systems, running mv on such a link terminated with a trailing slash moves the pointed-to directory and not the link itself.


-S suffix, --suffix=suffix

Override the SIMPLE_BACKUP_SUFFIX environment variable, which determines the suffix used for making simple backup files. If the suffix is not set either way, the default is a tilde (~).


--target-directory=dir

Move all sources into dir. This allows you to use mv together with xargs, which otherwise does not work, since the final argument would be the target.


-u, --update

Do not remove a file or link if its modification date is the same as or newer than that of its replacement.


-v, --verbose

Print the name of each file before moving it.

Mac OS X Options


-n

Do not overwrite an existing file. Overrides a previous -f or -i.


-v

Verbose; print filenames as they are moved.

nawk

     nawk [options] [program] [var=value ...] [files]

New version of the awk programming language. For more information see awk and Chapter 11.

nice

     nice [options] command [arguments]

Execute a command and arguments with lower priority (i.e., be "nice" to other users). Also built-in to the C shell, with a different command syntax (see Chapter 5).

Options


-n

Run command with a niceness of n (1 19); default is 10. Higher n means lower priority. A privileged user can raise priority by specifying a negative n (e.g., -5). nice works differently in the C shell (see Chapter 5). +n raises priority, -n lowers it, and 4 is the default.


-n n, --adjustment=n

Same as -n.

nl

     nl [options] [file]

Number the lines of file in logical page segments. Numbering resets to 1 at the start of each logical page. Pages consist of a header, body, and footer; each section may be empty. It is the body that gets numbered. The sections are delimited by special standalone lines as indicated next; the delimiter lines are copied to the output as empty lines.

Section Delimiters

\:\:\:

Start of header

\:\:

Start of body

\:

Start of footer


Common Options


-b type, --body-numbering=type

Number lines according to type. Values are:

a

All lines.

n

No lines.

t

Text lines only (the default).

p"exp"

Lines matching the regular expression exp only.



-d xy, --section-delimiter=xy

Use characters xy to delimit logical pages (default is \:).


-f type, --footer-numbering=type

Like -b, but number footer (default type is n).


-h type, --header-numbering=type

Like -b, but number header (default type is n).


-i n, --page-increment=n

Increment each line number by n (default is 1).


-l n, --join-blank-lines=n

Count n consecutive blank lines as one line.


-n format, --number-format=format

Set line number format. Values are:

ln

Left-justify, omit leading zeros.

rn

Right-justify, omit leading zeros (default).

rz

Right-justify.



-p, --no-renumber

Do not reset numbering at start of pages.


-s c, --number-separator=string

Separate text from line number with character(s) c (default is a tab).


-v n, --first-page=n

Number each page starting at n (default is 1).


-w n, --number-width=n

Use n columns to show line number (default is 6).

Examples

List the current directory, numbering files as 1), 2), etc.:

     ls | nl -w3 -s')  '

Number C source code and save it:

     nl prog.c > print_prog

Number only lines that begin with #include :

     nl -bp"^#include" prog.c

nm

     nm [options] objfiles

Print the symbol table (name list) in alphabetical order for one or more object files (usually ELF or COFF files), shared or static libraries, or binary executable programs. Output includes each symbol's value, type, size, name, etc. A key letter categorizing the symbol can also be displayed. You must supply at least one object file.

On Solaris, nm is in /usr/ccs/bin and /usr/xpg4/bin.

Common Options


-A, --print-file-name

Write the full pathname or library name on each line.


-g, --extern-only

Write only external (global) symbol information.


-P, --portability

Print output in the POSIX portable format.


-t radix, --radix=radix

Write numeric values in the specified radix : d for decimal, o for octal, and x for hexadecimal.


-u, --undefined-only

Report only the undefined symbols.

Solaris and GNU/Linux Options


-C, --demangle[= style]

Print demangled C++ symbol names. GNU/Linux lets you supply the appropriate demangling style.


-D, --dynamic

Print dynamic, not normal, symbols. Useful only when working with dynamic objects (some kinds of shared libraries, for example).


-V, --version

Print nm's version number on standard error.

GNU/Linux and Mac OS X Options


-a, --debug-syms

Print debugger symbols.


-n, --numeric-sort

Sort the external symbols numerically, not by name.


-p, --no-sort

Don't sort the symbols; print them in the order they are found in the object file.


-r, --reverse-sort

Sort in reverse order.

Solaris Options


-e

Report only external and static symbols; obsolete.


-f

Report all information; obsolete.


-h

Suppress the header.


-l

Use with -p; indicate WEAK symbols by appending an asterisk (*) to key letters.


-n

Sort the external symbols by name.


-o

Report values in octal.


-p

Precede each symbol with its key letter (used for parsing).


-r

Report the object file's name on each line.


-R

Print the archive name (if present), followed by the object file and symbol name. -r overrides this option.


-s

Print section name instead of section index.


-T

Truncate the symbol name in the display; obsolete.

Solaris /usr/xpg4/bin/nm Options


-u

Print output in long format.


-v

Sort the external symbols by value.


-x

Report values in hexadecimal.

GNU/Linux Options


-B

Same as --format=bsd (for compatibility with MIPS).


--defined-only

Display only defined symbols.


-f format, --format=format

Specify output format (bsd, sysv, or posix). Default is bsd.


-l, --line-numbers

Use debugging information to try to find line numbers for each symbol.


--no-demangle

Do not demangle C++ symbols.


-o

Same as -a.


-s, --print-armap

Print the index of files and symbols in ar archives.


--size-sort

Sort by size.


-S, --print-size

Print the size of defined symbols.


--target=bfdname

Use object code format bfdname, not the system default.


-v

Same as -n.


-X 32_64

For compatibility with AIX nm. Ignored.

Mac OS X Options


--arch type

Display information about only architecture type when running nm on a "fat" binary. Use all to see information about all architectures.


-f

Display the symbol table of a shared library as if it were a flat file.


-j

Display just the symbol names.


-l

Show a pseudo-symbol .section_start if no such symbol exists. Use together with -s.


-m

Display N_SECT (Mach-O) symbols with segment and section names and their status as external, nonexternal, undefined, common, absolute, or indirect.


-o

Include the filename or archive element name on each output line.


-s segname sectname

List only the symbols in (segname, sectname).


-x

Print entries in hexadecimal, with the name as a string.

Solaris Key Letters

Uppercase letters are used for GLOBAL and WEAK symbols. Lowercase letters are used for LOCAL symbols.

A

Absolute symbol.

B

BSS (uninitialized data space).

C

Common symbol.

D

Data object symbol.

F

File symbol.

L

Thread local storage.

N

Symbol with no type.

S

Section symbol.

T

Text symbol.

U

Undefined symbol.


nohup

     nohup command [arguments] &

Continue to execute the named command and optional command arguments after you log out (make command immune to hangups; i.e., no hangup). In the C shell, nohup is built in. In the Korn and Bash shells, nohup allows output redirection; output goes to nohup.out by default. In the Korn shell, nohup is an alias that allows the command it runs to also be aliased. (See Chapters 4 and 5.)

The Solaris /usr/bin/nohup accepts some rather specialized options; see the manpage for details.

nroff

     nroff [options] [files]

Format documents to line printer or to screen. See Chapter 18.

od

     od [options] [file] [[+] offset[. | b]]

Octal dump; produce a dump (normally octal) of the named file. file is displayed from its beginning, unless you specify an offset (normally in octal bytes). In the following options, a "word" is a 16-bit unit.

Common Options


-A base, --address-radix=base

Indicate how the offset should be written. Values for base are d for decimal, o for octal, x for hexadecimal, or n for no offset.


-b

Display bytes as octal.


-c

Display bytes as ASCII.


-d

Display words as unsigned decimal.


-f

Display 32-bit words as floating point.


-j skip, --skip-bytes=skip

Jump over skip bytes from the beginning of the input. skip can have a leading 0 or 0x for it to be treated as an octal or hexadecimal value. It can have a trailing b, k, or m to be treated as a multiple of 512, 1024, or 1,048,576 bytes.


-N count, --read-bytes=count

Process up to count input bytes.


-o

Display words as unsigned octal (the default).


-t type_string, --format=type_string

Specify one or more output types. See the "Common Type Strings" section later in this entry.


-v, --output-duplicates

Verbose; show all data. Without this, duplicate lines print as *.


-x

Display words as hexadecimal.[*]

[*] od -x is the canonical Unix oxymoron.


+

Required before offset if file isn't specified.

Solaris and Mac OS X Options


-D

Display 32-bit words as unsigned decimal.


-F

Display 64-bit words as extended precision.


-O

Display 32-bit words as unsigned octal.


-s

Display words as signed decimal.


-X

Display 32-bit words as hexadecimal.

GNU/Linux and Mac OS X Options


-a

Same as -t a.


-h

Same as -t x2.

Solaris Options


-C

Interpret bytes as characters based on the setting of LC_CTYPE.


-S

Display 32-bit words as signed decimal.

GNU/Linux Options


-i

Same as -t d2.


-l

Same as -t d4.


-s bytes, --strings[= bytes]

Output strings that are at least bytes ASCII graphic characters long (default is 3 if bytes is not specified for --strings).


--traditional

Accept arguments in the traditional form, which takes a single file specification with an optional offset and label. offset is an octal number indicating how many input bytes to skip over. label specifies an initial pseudo-address, which is printed in parentheses after any normal address. Both the offset and the label can begin with an optional plus sign (+), and can have a trailing decimal point (.) to force the offset to be interpreted as a decimal number and/or a trailing b to multiply the number of bytes skipped by offset by 512.


-w [ bytes], --width[= bytes]

Dump bytes input bytes to each output line. Defaults to 16 if this option is omitted. If --width is specified but bytes is omitted, the default is 32.

Mac OS X Options


-B

Same as -o.


-e

Same as -F.


-H

Same as -X.


-i

Same as -t dI.


-I, -l, -L

Same as -t dL.

Modifiers for offset


.

offset value is decimal.


b

offset value is 512-byte blocks. Solaris and Mac OS X also allow B.

Common Type Strings

Type strings can be followed by a decimal number indicating how many bytes to process.

a

ASCII named characters (e.g., BEL for \007)

c

Single- or multibyte characters

d, o, u, x

Signed decimal, unsigned octal, decimal, and hexadecimal

f

Floating point


passwd

     passwd [options] [user]

Create or change a password associated with a user name. Only the owner or a privileged user may change a password. Owners need not specify their user name.

Solaris and GNU/Linux Privileged User Options


-d, --delete

Delete password; user is no longer prompted for one.


-f, --force

Force expiration of user's password; user must change password at next login.


-l, --lock

Lock user's password; mutually exclusive with -d and -u.


-n days, --minimum=days

Set the minimum number of days that must pass before user can change his password.


-u, --unlock

Unlock user's password; mutually exclusive with -l.


-w days, --warning=days

Give user a warning beginning days days before his password is due to expire.


-x days, --maximum=days

Set the number of days before the password expires. Use a value of -1 (minus one) to disable password aging, 0 to force expiration like -f.

Solaris Options

Normal users may change the so-called gecos information (user's full name, office, etc.) and login shell when using NIS or NIS+; otherwise only privileged users may change the following:


-D domain

Use the passwd.org_dir database in the NIS+ domain domain, instead of in the local domain.


-e

Change the login shell.


-g

Change the gecos information.


-r db

Change the password in password database db, which is one of files, ldap, nis, or nisplus. Only a privileged user may use files.


-s

Display password information:

  1. user name.

  2. Password status (NP for no password, PS for password, LK for locked).

  3. The last time the password was changed (in mm/dd/yy format).

  4. Number of days that must pass before user can rechange the password.

  5. Number of days before the password expires.

  6. Number of days prior to expiration that user is warned of impending expiration.

The following may be used only by privileged users.


-a

Use with -s to display password information for all users. user should not be supplied.


-h

Change the home (login) directory.


-N

Disable user's password without locking it; mutually exclusive with -d.

GNU/Linux Options


-k, --keep-tokens

Keep authentication tokens that have not expired.


-i days, --inactive=days

After days days, disable inactive accounts.


--stdin

Read new password information from standard input.


-S, --status

Print a short status about user's password entry.


-?, --help, --usage

Print a command-line summary and exit.

Mac OS X Options


-i db

Change the password in db, which may be one of file, netinfo, nis, or opendirectory.


-l location

Change the password in location. Valid values vary based on the argument to -i:

file

A filename. Default is /etc/master.passwd.

netinfo

A domain name or server/tag pair.

nis

An NIS domain name.

opendirectory

A directory node name.


paste

     paste [options] files

Merge corresponding lines of one or more files into vertical columns, separated by a tab. See also cut, join, and pr.

Options


-

Replace a filename with the standard input.


-d char, --delimiters=char

Separate columns with char instead of a tab. char can be any regular character or the following escape sequences:

\n

Newline

\t

Tab

\\

Backslash

\0

Empty string


Note: you can separate columns with different characters by supplying more than one char.


-s, --serial

Merge subsequent lines from one file.

Examples

Create a three-column result file results from the files in1.data, in2.data, and in3.data:

     paste in1.data in2.data in3.data > results

List users in two columns:

     who | paste - -

Merge each pair of lines into one line:

     paste -s -d"\t\n" list

patch

     patch [options] [original [patchfile]]

Apply the patches specified in patchfile to original. Replace the original with the new, patched version; move the original to original.orig or original~. The patch file is a difference listing produced by the diff command. On Solaris, this command is named gpatch.

URL: http://www.gnu.org/software/patch.

Options


-b, --backup

Back up the original file.


--backup-if-mismatch, --no-backup-if-mismatch

When not backing up all original files, these options control whether a backup should be made when a patch does not match the original file. The default is to make backups unless --posix is specified.


--binary

Read and write files as binary. Has no effect on a Unix system.


-B prefix, --prefix=prefix

Prepend prefix to the backup filename.


-c, --context

Interpret patchfile as a context diff.


-d dir, --directory=dir

cd to directory before beginning patch operations.


--dry-run

Print the results of applying a patch, but don't change any files.


-D string, --ifdef=string

Mark all changes with:

#ifdef string        ...     #endif


-e, --ed

Treat the contents of patchfile as ed commands.


-E, --remove-empty-files

If patch creates any empty files, delete them.


-f, --force

Force all changes, even those that look incorrect. Skip patches if the original file does not exist; force patches for files with the wrong version specified; assume patches are never reversed.


-F num, --fuzz=num

Specify the maximum number of lines that may be ignored (fuzzed over) when deciding where to install a hunk of code. The default is 2. Meaningful only with context diffs.


-g num, --get num

Specify whether to check the original file out of source control if it is missing or read-only. If num is a positive number, get the file. If it is negative, prompt the user. If it is 0, do not check files out of source control. The default is negative or the value of the PATCH_GET environment variable when set, unless the --posix option is given. Then the default is 0.


-i file, --input=file

Read patch from file instead of standard input.


-l, --ignore-whitespace

Ignore whitespace while pattern matching.


-n, --normal

Interpret patch file as a normal diff.


-N, --forward

Ignore patches that appear to be reversed or to have already been applied.


-o file, --output=file

Print output to file.


-p[ num], --strip[= num]

Specify how much of preceding pathname to strip. A num of 0 strips everything, leaving just the filename. 1 strips the leading /. Each higher number after that strips another directory from the left.


--posix

Conform more strictly to the POSIX standard.


--quoting-style=style

Set the quoting style used when printing names. The default style is shell unless set by the environment variable QUOTING_STYLE. style may be one of the following:

c

Quote as a C language string.

escape

Like c, but without surrounding double-quote characters.

literal

Print without quoting.

shell

Quote for use in shell when needed.

shell-always

Quote for use in shell even if not needed.



-r file, --reject-file=file

Place rejects (hunks of the patch file that patch fails to place within the original file) in file. Default is original.rej.


-R, --reverse

Do a reverse patch: attempt to undo the damage done by patching with the old and new files reversed.


-s, --silent, --quiet

Suppress commentary.


-t, --batch

Skip patches if the original file does not exist.


-T, --set-time

When original file timestamps match the times given in the patch header, set timestamps for patched files according to the context diff headers. Use option -f to force date changes. Assume timestamps are in local time.


-u, --unified

Interpret patch file as a unified context diff.


-v, --version

Print version number and exit.


--verbose

Verbose mode.


-V method, --version-control=method

Specify method for creating backup files (overridden by -B):

t, numbered

Make numbered backups.

nil, existing

Back up files according to preexisting backup schemes, with simple backups as the default. This is patch's default behavior.

never, simple

Make simple backups.



-Y prefix, --basename-prefix=prefix

Use the specified prefix with a file's basename to create backup filenames. Useful for specifying a directory.


-z suffix, --suffix=suffix

Back up the original file in original.suffix.


-Z, --set-utc

When original file timestamps match the times given in the patch header, set timestamps for patched files according to the context diff headers. Use option -f to force date changes. Assume timestamps are in Coordinated Universal Time (UTC).

Example

Update a software distribution:

     $ cd whizprog-1.1      $ patch --verbose --backup -p1 < whizprog-1.1-1.2.diff       Lots of messages here as patch works     $ find . -name '*.orig' -print | xargs rm      $ cd ..      $ mv whizprog-1.1 whizprog-1.2 

pathchk

     pathchk [-p] pathnames

Check pathnames. This command verifies that the file(s) named by pathnames do not violate any constraints of the underlying filesystem (such as a name that might be too long), and that the files could be accessed (e.g., if an intermediate directory lacks search permission, it is a problem). The -p option provides additional portability checks for the pathnames. GNU/Linux provides --portability as another name for -p.

pax

     pax [options] [patterns]

Portable Archive Exchange program. When members of the first POSIX 1003.2 working group could not standardize on either tar or cpio, they invented this program.[*] (See also cpio and tar.)

[*] This period in Unix history is known as the "tar wars." :-)

GNU/Linux and Mac OS X use almost identical versions of pax, developed by the OpenBSD team, based on the original freely available version by Keith Muller.

pax operates in four modes, depending on the combinations of -r and -w:


List mode

No -r and no -w. List the contents of a pax archive. Optionally, restrict the output to filenames and/or directories that match a given pattern.


Extract mode

-r only. Extract files from a pax archive. Intermediate directories are created as needed.


Archive mode

-w only. Archive files to a new or existing pax archive. The archive is written to standard output; it may be redirected to an appropriate tape device if needed for backups.


Pass-through mode

-r and -w. Copy a directory tree from one location to another, analogous to cpio -p.

Common Options

Here are the options available in the four modes:

     None:       c d f           n     s     v     -r:         c d f   i k     n o p s   u v     -w:     a b   d f H i     L   o   s t u v x X     -rw:          d   H i k l   n   p s t u v   X


-a

Append files to the archive. This may not work on some tape devices.


-b size

Use size as the blocksize, in bytes, of blocks to be written to the archive.


-c

Complement. Match all file or archive members that do not match the patterns.


-d

For files or archive members that are directories, extract or archive only the directory itself, not the tree it contains.


-f archive

Use archive instead of standard input or standard output.


-H

Follow symbolic links named on the command line, archiving the pointed-to file or directory.


-i

Interactively rename files. For each file, pax writes a prompt to /dev/tty and reads a one-line response from /dev/tty. The responses are as follows:

ENTER

Skip the file.

A period

Take the file as is.

new name

Anything else is taken as the new name to use for the file.

EOF

Exit immediately with a nonzero exit status.



-k

Do not overwrite existing files.


-l

Make hard links. When copying a directory tree (-rw), make hard links between the source and destination hierarchies wherever possible.


-L

Follow all symbolic links, archiving the pointed-to file or directory.


-n

Choose the first archive member that matches each pattern. No more than one archive member will match for each pattern.


-o options

Reserved for format-specific options.


-p privs

Specify one or more privileges for the extracted file. privs specify permissions or other characteristics to be preserved or ignored, as follows:

a

Do not preserve file access times.

e

Retain the user and group IDs, permissions (mode), and access and modification time.

m

Do not preserve the file modification time.

o

Retain the user and group ID.

p

Keep the permissions (mode).



-r

Read an archive and extract files.


-s replacement

Use replacement to modify file or archive member names. This is a string of the form -s/old/new/[gp]. This is similar to the substitution commands in ed, ex, and sed. old is a regular expression, and new may contain & to mean the matched text and \n for subpatterns. The trailing g indicates the substitution should be applied globally. A trailing p causes pax to print the resulting new filename. Multiple -s options may be supplied. The first one that works is applied. Any delimiter may be used, not just /, but in all cases it is wise to quote the argument to prevent the shell from expanding wildcard characters.


-t

Reset the access time of archived files to what they were before being archived by pax.


-u

Ignore files older than preexisting files or archive members. The behavior varies based on the current mode.


Extract mode

Extract the archive file if it is newer than an existing file with the same name.


Archive mode

If an existing file with the same name as an archive member is newer than the archive member, supersede the archive member.


Pass-through mode

Replace the file in the destination hierarchy with the file in the source hierarchy (or a link to it) if the source hierarchy's file is newer.


-v

In list mode, print a verbose table of contents. Otherwise, print archive member names on standard error.


-w

Write files to standard output in the given archive format.


-x format

Use the given format for the archive. The value of format is one of cpio, pax, or ustar. The details of the formats are provided in the IEEE 1003.1 (2004) POSIX standard. The formats are mutually incompatible; attempting to append using one format to an archive using another is an error.

Solaris provides the xustar format, which allows archiving files over 8GB in size.

Mac OS X and GNU/Linux provide the bcpio, sv4cpio, sv4crc, and tar formats, which provide compatibility with various historical versions of tar and cpio.


-X

When traversing directory trees, do not cross into a directory on a different device (the st_dev field in the stat structure, see stat (2); similar to the -mount option of find).

Solaris Options


-@

Archive or extract extended attributes.

GNU/Linux and Mac OS X Options


-B bytes

Write no more than bytes bytes for each volume. Intended for use on tape media, not recommended for floppies or hard disks. bytes may be suffixed with m, k, or b to specify units of megabytes, kilobytes, or 512-byte blocks, respectively.


-D

Like -u, but check the file's inode-change time instead of the modification time.


-E count

Retry failed reads no more than count times. A limit of 0 causes pax to stop after the first read failure. A limit of NONE causes pax to retry forever, which could cause an infinite loop when reading from very poor media.


-G group

Select files based on the group ownership. Use #number to supply a numeric GID. Use \# if the group name contains a literal # character. Multiple -G options may be supplied.


-P

Do not follow any symbolic links. This is the default.


-T [ from_date][, to_date][/[c ][m ]]

Choose files based on modification time or inode change time whose times fall within a specified range. With just from_date, select files of same age or younger. With just to_date, select files of same age or older. With both, choose files falling within the given dates. If the two dates are equal, the file's time must exactly match the given date. The trailing c and m let you specify which timestamp to compare against: inode change time or modification time, respectively. If both are used, both times are compared. The default is the modification time. Multiple -T options may be provided; the first one that matches a given file is used.

The time is specified as [yy[mm[dd[hh]]]]mm[.ss]. Only the minutes (mm) field is required. Other fields may be added, but no intervening fields may be omitted (e.g., you can't provide the day of the month without also providing the hour). Times are relative to the current time; thus an hhmm specification is relative to today.


-U user

Select files based on the user. Use #number to supply a numeric UID. Use \# if the username contains a literal # character. Multiple -U options may be supplied.


-Y

Like -D, but check the inode change time of the pathname created after all filename substitutions have occurred.


-z

Use gzip to compress/decompress the archive when writing/reading. Mutually exclusive with -a.


-Z

Like -u, but check the modification time of the pathname created after all filename substitutions have occurred.

Examples

Copy the current directory to tape:

     pax -x ustar -w -f /dev/rmt/0m .

Copy a home directory to a different directory (presumably on a bigger disk).

     # cd /home     # pax -r -w arnold /newhome

perl

     perl [options] [programfile] [files]

perl is the interpreter for the Perl programming language (the Swiss Army knife of Unix programming tools). The Perl program is provided via one or more -e options. If no -e options are used, the first file named on the command line is used for the program. See perlrun (1) for the full list of options.

For more information about Perl, see Learning Perl, Programming Perl, and Advanced Perl Programming, all listed in the Bibliography.

URLs: http://www.perl.org and http://www.perl.com.

pr

     pr [options] [files]

Format one or more files according to options to standard output. Each page includes a heading that consists of the page number, filename, date, and time. When files are named directly, the date and time are those of the file's modification time. Otherwise, the current date and time are used.

Common Options


-a, --across

Multicolumn format; list items in rows going across.


-d, --double-space

Double-spaced format.


-e[ tab-char[ width]], --expand-tabs=[ tab-char[ width]]

Convert tabs (or tab-chars) to spaces. If width is specified, convert tabs to width characters (default is 8).


-F, --form-feed

Separate pages with form feeds, not newlines. (Solaris /usr/bin/pr folds input lines, avoiding truncation by -a or -m.)


-h str, --header=str

Replace default header with string str.


-i[ out-tab-char[ out-tab-width]]


--output-tabs[= out-tab-char[ out-tab-width]]

Replace spaces with tabs on output. Can specify alternative tab character (default is tab) and width (default is 8).


-l n, --length=n

Set page length to n lines (default is 66).


-m, --merge

Merge files, printing one in each column (can't be used with -n and -a). Text is chopped to fit. See also paste.


-n[ delimiter[ digits]], --number-lines[= delimiter[ digits]]

Number columns, or, with the -m option, number lines. Append delimiter to each number (default is a tab) and limit the size of numbers to digits (default is 5).


-o n, --indent=n

Offset each line n spaces (default is 0).


-r, --no-file-warnings

Suppress messages for files that can't be found.


-s[ delimiter], --separator[= delimiter]

Separate columns with delimiter (default is a tab).


-t, --omit-header

Omit the page header and trailing blank lines.


-w n, --width=n

Set line width to n (default is 72).


+ beg_page[: end-page], --pages=[ beg_page[: end-page]

Begin printing at page beg_page (default is 1). The GNU/Linux version supports supplying an end page end_page also.


-n, --columns=n

Produce output having n columns (default is 1); tabs are expanded as with -i.

Solaris Options


-f

Separate pages using a formfeed character (^L) instead of a series of blank lines.


-p

Pause before each page.

GNU/Linux Options


-c, --show-control-chars

Convert control characters to hat notation (such as ^C), and other unprintable characters to octal backslash format.


-D format, --date-format=format

Format the header date using format. See the date command for the possible formats.


-f

Same as -F.


-J, --join-lines

Merge full lines; ignore -W if set.


-N num, --first-line-number=num

Start counting with num at the first line of the first page printed. Also see +beg_page.


-S[ string], --sep-string[= string]

Separate columns with string. Default is a tab with -J and a space otherwise.


-T, --omit-pagination

Like -t but also suppress form feeds.


-v, --show-non-printing

Convert unprintable characters to octal backslash format.

Mac OS X Options


-f

Like -F, but pause before printing the first page.


-L locale

Use locale for the locale, instead of what's in the environment.


-p

Pause before each page.

Examples

Print a side-by-side list, omitting heading and extra lines:

     pr -m -t list.1 list.2 list.3

Alphabetize a list of states; number the lines in five columns:

     sort states_50 | pr -n -5

printenv

     printenv [variable]

Print values of all environment variables or, optionally, only the specified variable. The more standard alternative, env, doesn't let you view just one variable, but it lets you redefine them. On Solaris, printenv is in /usr/ucb.

printf

     printf formats [strings]

Print strings using the specified formats. formats can be ordinary text characters, C-language escape characters, printf (3S) format conversion specifiers, or, more commonly, a set of conversion arguments listed next.

printf is built into Bash and ksh93 (see Chapter 4); this entry describes the external version in /usr/bin/printf.


Common Arguments


%b

Process a string argument for backslash escapes (not in printf (3S)). See the description of allowed escapes under echo.


%s

Print the next string.


%[- ]m[. n]s

Print the next string, using a field that is m characters wide. Optionally limit the field to print only the first n characters of string. Strings are right-adjusted unless the left-adjustment flag - is specified.

Solaris Argument


% n$s

Print the nth string.

Examples

$ printf '%s %s\n' "My files are in" $HOME     My files are in /home/arnold     $ printf '%-25.15s %s\n' "My files are in" $HOME     My files are in           /home/arnold

ps

     ps [options] [arguments]

Process status. This command is very system-specific. See the ps entries in the sections for each operating system.

pwd

     pwd

Print the full pathname of the current directory. (Command name stands for "print working directory.") Note: the built-in versions, pwd (Bash and Korn shells) and dirs (C shell), are faster, so you might want to define the following C shell alias:

     alias pwd dirs -l

python

     python

A powerful object-oriented scripting language often compared to Perl or Java. python drives many of the configuration scripts used in Red Hat and other Linux distributions. For more information, see Learning Python and Programming Python.

URL: http://www.python.org.

r Commands

     rcp [options] file1 file2     rcp [options] file ... directory     rlogin [options] rhost     rsh [options] host [command]

The BSD "r" commands provide remote file copy, remote login, and remote command execution across a TCP/IP network. In the 21st century these commands are considered to be terribly insecure, and you should never use them. Instead, consider the secure versions that come as part of the Secure Shell: scp, slogin, and ssh (see ssh).

rcs

     rcs [options] files

The Revision Control System (RCS) keeps track of multiple versions of files, letting you store and retrieve revisions and track the history of the files. The rcs command creates new RCS files and modifies attributes of existing files. See Chapter 13 for more information on RCS and its commands.

reset

     reset [options] [terminal]

Clear screen (reset terminal). If terminal is specified on the command line, the value is used as the terminal type. reset is a symbolic link to the tset command. Invoking the command as reset is useful for clearing your terminal when a program dies and leaves the terminal in an abnormal state. You may have to run the command with a linefeed character (usually CTRL-J) before and after it:

     CTRL-J reset CTRL-J

On Solaris, this command is found is /usr/ucb. See the tset entry for the available options.

rm

     rm [options] files

Delete one or more files. To remove a file, you must have write permission on the directory that contains the file, but you need not have permission on the file itself. If you do not have write permission on the file, you are prompted (y or n) to override.

Common Options


-f, --force

Force. Remove write-protected files without prompting.


-i, --interactive

Prompt for y (remove the file) or n (do not remove the file). Overrides -f.


-r, -R, --recursive

If file is a directory, remove the entire directory and all its contents, including subdirectories. Be forewarned: use of this option can be dangerous.


--

Mark the end of options (rm still accepts -, the old form). Use this when supplying a filename beginning with -.

GNU/Linux and Mac OS X Options


-d, --directory

Remove directories, even if they are not empty. Available only to a privileged user.


-v, --verbose

Verbose mode (print the name of each file before removing it).

GNU/Linux Options


--no-preserve-root

Do not treat the root directory, /, specially.


--preserve-root

Do not operate recursively on the root directory, /.

Mac OS X Options


-P

Overwrite the contents of the to-be-removed files before deleting them. Each file is written with three different bit patterns: 0xff, 0x00, and then 0xff again.


-W

Undelete the named files. Only works for files covered by whiteouts.

rmdir

     rmdir [options] directories

Delete the named directories (the directory itself, not the contents). directories are deleted from the parent directory and must be empty (if not, rm -r can be used instead). See also mkdir.

Common Option


-p, --parents

Remove directories and any intervening parent directories that become empty as a result; useful for removing subdirectory trees.

Solaris Option


-s

Suppress standard error messages caused by -p.

GNU/Linux Options


--ignore-fail-on-non-empty

Ignore failure to remove directories that are not empty.


-v, --verbose

Verbose mode; print a message for each directory as it is processed.

rsync

     rsync [options] source ... dest

rsync synchronizes files across a network connection. It is particularly good for high-latency connections, and for synchronizing entire directory trees across machines. On Solaris, rsync is in /opt/sfw/bin; it may not be installed on your system. However, you can download it and compile and install it. This entry documents rsync 2.6.5, which is the most recent as of the time of this writing.

URL: http://rsync.samba.org/.

Source and destination specifications take three forms:


Pathname

A regular Unix pathname, representing a local file.


[ user@ ]host:[ path]

The file or directory path on remote host host as remote user user. With a single colon, rsync uses a remote shell such as ssh or rsh for its transfer mechanism. The remote username is optional, and the remote path defaults to the current users's home directory on the remote system. A relative path (one that does not start with /) is relative to the home directory on the remote system.


[ user@ ]host::[ path]

The file or directory path on remote host host as remote user user. With a double colon, rsync makes a direct TCP connection to port 873 on the remote machine, and expects to talk to another copy of rsync running in daemon mode.

If both source and destination are local pathnames, rsync synchronizes the two local files or directory trees. You may not specify a remote source together with a remote destination.

Using a trailing / on a directory name causes rsync to work on the contents of that directory, instead of starting with and copying the directory itself.

Primary Options

rsync has a large number of options. We document the most useful ones here; see the manpage for more information.


-a, --archive

Same as -rlptgoD. This provides recursion and synchronizes almost everything. Add -H to preserve hard links.


-b, --backup

Backup preexisting files before copying them.


--backup-dir=dir

With -b, indicates that backup copies should be stored in dir.


-c, --checksum

Use 128-bit MD4 checksums during the transfer. This increases reliability but severely slows down the synchronization.


-C, --cvs-exclude

Ignore the same files that CVS would. rsync starts with this list:

RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS .make.state .nse_depinfo *~ #* .#* ,* _$* *$ *.old *.bak .BAK *.orig *.rej .del-* *.a *.olb *.o *.obj *.so *.exe *.Z *.elc *.ln core .svn/

It then adds files listed $HOME/.cvsignore and those in the CVSIGNORE environment variable. As it traverse directories, when it finds a .cvsignore file, rsync also ignores files listed therein. These rules are applied after --filter rules you supply.


--delete

Delete files on the receiving side that are not on the sending side. This applies only for recursive directory copies, not for individual files. Use with caution. You may wish to use -n first. See the manpage for details on this and other related options.


-e program, --rsh=program

Use program as the remote shell for communication with the remote system. By default, modern versions of rsync use ssh, the Secure Shell, but it's possible that rsync was configured differently. If you provide program as a quoted argument, you can include command-line arguments for it.


--exclude=pattern

Exclude files matching pattern. You can usually think of pattern as a shell-style wildcard; however, much more powerful patterns are possible; see the manpage for more information.


-g, --group

Make the group of the destination file be the same as the group of the source file. Only groups in the remote user's group set may be used. The default is to use group names, but sometimes numeric GID values are used; see the manpage for the details.


-h, --help

Print a command-line summary and exit.


-H, --hard-links

Preserve hard link information when copying files. This only works if both links are in the files being copied. This option can be slow, since rsync must keep track of more information.


--include=pattern

Include only files matching pattern. You can usually think of pattern as a shell-style wildcard; however, much more powerful patterns are possible; see the manpage for more information.


-l, --links

Re-create source symbolic links as symbolic links on the destination system.


-L, --copy-links

Follow symbolic links, copying the files they point to, not the symbolic links themselves.


-n, --dry-run

Do not actually transfer any files, just report what would happen.


-o, --owner

Make the owner of the destination file be the same as the owner of the source file. Often, changing ownership is a privileged operation, so this may not always work. The default is to use usernames, but sometimes numeric UID values are used; see the manpage for the details.


-p, --perms

Make the destination permissions be the same as the source permissions. Normally permissions on existing files are not changed.


--progress

Print running progress information during the transfer.


-q, --quiet

Decrease information during a transfer. Useful if invoking rsync from cron.


-r, --recursive

Copy directories recursively.


--rsync-path=program

Specify the path to the remote copy of rsync. Use this when rsync is not included in the PATH of the remote shell. The program is run on the remote system by a real shell, so it can be a (small) shell script; just be careful that it does not produce any output or read any input, so that rsync's communications are not affected.


-S, --sparse

Attempt to be efficient when transfering sparse files (those with holes in them) so that they take up less space on the destination system. Note: the manpage warns against using this option for destinations on Solaris tmpfs filesystems.


-t, --times

Make the modification time of the destination file be the same as that of the source file. You should always do this; it enables optimizations within rsync that make subsequent updates go faster.


-u, --update

Skip any destination files that have a newer modification time than the source file. Note, however, that the modification time doesn't matter if the files have a different type, for example a symbolic link source and a regular file destination; in such a case the update is always done.


-v, --verbose

Increase information during a transfer. Repeating the option increases verbosity; however, more than two -v options is useful only for debugging.


-x, --one-file-system

Do not cross filesystem boundaries when recursively copying directory trees.


-z, --compress

Compress file data as it's sent. Due to the way rsync works, this can achieve better performance than just using a remote shell that compresses data.


-0, --from0

Filenames read from a file are terminated with the zero byte, instead of a newline. This provides unambiguous interpretation of filenames. It does not apply to .cvsignore files.

See the manpage for a description of the other options.

Examples

Mirror a directory tree from an rsync server:

     rsync -avz archive.example.com::Cool_Stuff .

Synchronize the home directory on your laptop with that of your desktop system. Assume that the full path to your home directory is the same on both, and that you're using Bash or the Korn shell:

     laptop$ cd $HOME     laptop$ rsync -aHzv --delete desktop.example.com:$PWD/ ./

samba

     Samba   Tools For Working With SMB Filesystems

The Samba suite allows you to serve Unix filesystems to MS-Windows clients. It also allows you to make Unix printers available to MS-Windows systems. It provides considerable interoperability with those systems. Samba comes with GNU/Linux, and GNU/Linux systems can also mount SMB fileshares.

URL: http://www.samba.org.

scp

     scp [options] file1 [...] file2

Securely copy files between hosts on a network, using ssh. Part of the OpenSSH suite of network tools. (See also ssh and sftp.) scp requests a password or passphrase if required. The transfer can be between two remote hosts. If more than one file is specified for file1, file2 should be a directory; otherwise, only the last file in the list is copied. file1 and file2 can be specified in any of the following ways:

     file     host:file     user@host:file

Common Options


-4

Use IPv4 addresses.


-6

Use IPv6 addresses.


-B

Run in batch mode. Don't ask for passwords or passphrases.


-c cipher

Specify the cipher to be used for encrypting the data.


-C

Enable ssh compression.


-F file

Use file as the per-user configuration file.


-i file

Specify the file that contains the identity (private key) for RSA authentication.


-o option

Specify an option to pass to ssh.


-p

Preserve modification time, access time, and mode.


-P port

Connect to port on the remote host.


-q

Don't display the progress meter.


-r

Copy directories recursively.


-S program

Specify the program to use for the encrypted connection. The program must understand ssh options.


-v

Verbose mode.

GNU/Linux and Mac OS X Options


-1

Force use of the SSH1 protocol.


-2

Force use of the SSH2 protocol.


-l count

Limit the bandwidth used to count Kbits per second.

Mac OS X Option


-E

Preserve extended attributes, such as resource forks. Both ends of the connection must be running Mac OS X 10.4 or later.

screen

     screen [options] [command [args]]

Provide ANSI/VT100 terminal emulation, making it possible to run multiple full-screen pseudo-terminals from one real terminal, and letting you manipulate and save your screen input and output, copy and paste between windows, etc. Solaris does not have screen, but you can download and build it.

URL: http://www.gnu.org/software/screen.

Options


-a

Include all capabilities in each window's termcap.


-A

Adapt all windows to the size of the current terminal. Default is to try to use the previous window size.


-c file

Use file as the configuration file instead of the default $HOME/.screenrc.


-d

Detach session running elsewhere. With -r, reattach to this terminal. With -R, reattach to this terminal or create it if it doesn't already exist. With -RR, use the first session when reattaching if more than one session is available. With -m, start in detached mode.


-D

Detach session running elsewhere, logging out before detaching. With -r, reattach to this terminal. With -R, reattach to this terminal or create it if it doesn't already exist. With -RR, do whatever is necessary to create a new session. With -m, start in detached mode, but don't fork a new process.


-e xy

Change command characters. Specify x as the command character (default CTRL-A) and y as the character that generates a literal command character (default a). Specify in caret notation (e.g., ^A for CTRL-A).


-f, -fn, -fa

Turn flow control on, off, or to automatic switching mode.


-h num

Specify the size of the history scrollback buffer.


-i

Cause the interrupt key (usually CTRL-C) to interrupt the display immediately when flow control is on. Use of this option is discouraged.


-l, -ln

Turn login mode on or off for /var/adm/utmp updating. (The actual filename varies from system to system.)


-ls, -list

Print list of pid.tty.host strings identifying screen sessions.


-L

Tell screen that automargin terminal has a writable last position.


-m

Ignore the $STY environment variable and create a new session. With -d, start session in detached mode; useful for scripts. With -D, start session in detached mode but don't fork a new process; the command exits if the session terminates.


-O

Use optimal output mode for terminal rather than true VT100 emulation.


-p window

Preselect the specified window if it exists.


-q

Suppress error message printing on startup. Exit with nonzero return code if unsuccessful.


-r [ pid.tty.host] -r sessionowner/[ pid.tty.host]

Resume detached session. No other options except -d or -D can be specified. With sessionowner, resume another user's detached session; requires setuid root.


-R

Attempt to resume the first session found, or start a new session with the specified options. Set by default if screen is run as a login shell.


-s shell

Set the default shell, overriding the $SHELL environment variable.


-S name

Specify a name for the session being started.


-t name

Set the window's title.


-T term

Set $TERM to term instead of screen.


-U

Run in UTF-8 mode.


-v

Print version information and exit.


-wipe [ match]

Like -ls, but remove destroyed sessions instead of marking them dead. If a match is specified, it should be in the same form as the argument to the -r option.


-x

Attach to a session that is not detached. Requires multi-display mode.


-X

Run specified command in specified session. Requires multi-display mode, and session must not be password-protected.

script

     script [options] [file]

Create a record of your login session, storing in file everything that displays on your screen. The default file is called typescript. script records nonprinting characters as control characters and includes prompts. This command is useful for beginners or for saving output from a time-consuming command.

Common Option


-a

Append the script record to file.

GNU/Linux Options


-c command

Run command instead of creating an interactive shell. Useful for capturing the output of a command that acts differently when it's connected to a terminal.


-f

Flush output after each write. Useful if another person is monitoring the output file.


-q

Operate in quiet mode.


-t

Write timing data to standard error. Each entry has two fields: the first is the elapsed time since the last output, and the second is the number of characters in the current output.

sdiff

     sdiff [options] file1 file2

Produce a side-by-side comparison of file1 with file2. Output is:


text text

Identical lines.


text <

Line that exists only in file1.


> text

Line that exists only in file2.


text | text

Lines that are different.

GNU/Linux and Mac OS X both use the GNU version of sdiff.

Common Options


-l, --left-column

List only lines of file1 that are identical.


-o outfile, --output=outfile

Send identical lines of file1 and file2 to outfile; print line differences and edit outfile by entering, when prompted, the following commands:

e

Edit an empty file.

e b

Edit both left and right columns.

e l

Edit left column.

e r

Edit right column.

l

Append left column to outfile.

q

Exit the editor.

r

Append right column to outfile.

s

Silent mode; do not print identical lines.

v

Turn off "silent mode."



-s, --suppress-common-lines

Do not print identical lines.


-w cols, --width=cols

Set line length to cols (default is 130).

GNU sdiff Options


-a, --text

Treat all files as text and compare line-by-line.


-b, --ignore-space-change

Ignore differences in whitespace.


-B, --ignore-blank-lines

Ignore added or missing blank lines.


-d, --minimal

Use a different algorithm to find fewer changes. This option causes sdiff to run more slowly.


--diff-program=program

Use program in place of the standard version of diff.


-E, --ignore-tab-expansion

Ignore changes occurring because of tab expansion.


-H, --speed-large-files

Heuristically speed comparison of large files with many small scattered changes.


-i, --ignore-case

Ignore case changes.


--ignore-all-space

Ignore whitespace when comparing lines.


-I regexp, --ignore-matching-lines=regexp

Ignore any changes that insert or delete lines matching the regular expression regexp.


--strip-trailing-cr

Ignore Carriage Return characters at the end of input lines.


-t, --expand-tabs

Convert tabs to spaces in the output to preserve alignment.


-v, --version

Print version information and exit.


-W, --ignore-all-space

Ignore horizontal whitespace when comparing lines.

Example

Show differences using 80 columns and ignore identical lines:

     sdiff -s -w80 list.1 list.2

sed

     sed [options] [files]

Stream editor. Edit one or more files without user interaction. See Chapter 10 for more information on sed. The -e and -f options may be provided multiple times, and they may be used with each other. See also sed & awk, cited in the Bibliography.

Common Options


-e ' instruction' , --expression=' instruction'

Apply the editing instruction to the files.


-f script, --file=script

Apply the set of instructions from the editing script.


-n, --quiet, --silent

Suppress default output.

GNU/Linux and Mac OS X Option


-i [ suffix], --in-place=[ suffix]

Edit files in place, saving each original in a file created by concatenating suffix to the filename. A zero length suffix does not save a backup copy; this is not recommended.

GNU/Linux Options


-l count, --line-length=count

Wrap lines at column count for the l command.


--posix

Disable all GNU extensions.


-r, --regex-extended

Use Extended Regular Expressions instead of Basic Regular Expressions (see Chapter 7).


-s, --separate

Process each file separately instead of treating them all as one long input stream.


-u, --unbuffered

Do not keep as much data in memory as sed would normally; flush output buffers more often.

Mac OS X Option


-E

Use Extended Regular Expressions instead of Basic Regular Expressions (see Chapter 7).

sftp

     sftp [options] host

An interactive file transfer program, similar to ftp except that it uses ssh to perform file transfers securely. sftp connects to host and logs in, prompting for a password if required. The host can be specified in the following ways:

     host     [user@]host[:file [file] ...]     [user@]host[:dir[/]]

If user is specified, that username is used for the login. If any files are specified, the sftp client automatically retrieves them after the user has been authenticated and then exits. If a directory dir is specified, the client starts in that directory on the remote host. sftp is part of the OpenSSH suite of network tools. See also ssh and scp.

Options


-1

Use SSH1. The default is to use SSH2.


-b file

Run in batch mode, taking commands from the specified file. Requires a noninteractive authentication mechanism.


-B bytes

Specify the size of the buffer sftp uses for file transfers. Default is 32768 bytes.


-C

Enable compression (uses ssh -C).


-F file

Use file as the ssh configuration file instead of the default system configuration file. The system-wide file is usually /etc/ssh/ssh_config and per-user files are $HOME/.ssh/config.


-ooption

Pass an option to ssh. The passed option is in the format used by ssh_config(5) (e.g., -oPORT=nn, where nn is the port number). -o can appear more than once to pass multiple options to ssh. This option is useful for passing options that don't have an equivalent sftp command-line option.


-P server_path

Connect directly to the local sftp server specified in server_path. Useful for debugging.


-R num

Specify the number of requests that may be outstanding at any time (default is 16).


-s subsys|server_path

Specify the SSH2 subsystem or path to the sftp server on the remote system. Specifying the path is useful for using sftp via SSH1 or if the remote sshd does not have an sftp subsystem configured.


-S program

Specify the name of a program that understands ssh options and that you want to use for the encrypted connection.


-v

Raise the logging level.

sh

     sh [options] [arguments]

The standard command interpreter that executes commands from a terminal or a file. On commercial Unix systems, /bin/sh is often the original Bourne shell, which lacks features found in Bash and the Korn shell.

On some systems, /bin/sh may be a version of ksh88. (This is true of Solaris's /usr/xpg4/bin/sh.) On GNU/Linux, /bin/sh is a symbolic link to Bash, while on Mac OS X /bin/sh is a separate copy of Bash. See Chapter 4 for more information on Bash, ksh88, and ksh93, including command-line options.

size

     size [options] [objfile ...]

Print the (decimal) number of bytes of each section of objfile. On many systems, if objfile is not specified, a.out is used. Solaris requires the objfile name. On Solaris, this program resides in /usr/ccs/bin.

Like the loader ld, this program has diverged across time and platforms, to the point where it's not worthwhile to provide an option list. The output format is also not the same across systems. See the manpage for your local system.

sleep

     sleep seconds

Wait a specified number of seconds before executing another command. Often used in shell scripts. sleep is built in to ksh93.

The GNU/Linux version allows the number to have a suffix: s for seconds (the default), m for minutes, h for hours, and d for days. The value may also be real number, specifying fractional units as well.

soelim

     soelim [files]

A preprocessor that reads nroff/troff input files, resolving and then eliminating .so requests. That is, input lines such as:

     .so header

are replaced by the contents of the file header. Normally, .so requests are resolved by nroff or troff. Use soelim whenever you are preprocessing the input (e.g., passing it through tbl or sed), and the complete text is needed prior to formatting. See also Chapter 18.

Example

Run a sed script on (all) input before formatting:

     soelim file | sed -e 's/--/\\(em/g' | nroff -mm - | lp

sort

     sort [options] [files]

Sort the lines of the named files, typically in alphabetical order. See also uniq, comm, and join.

Mac OS X uses an early version of GNU sort that lacks long options as well as some of the features of the current GNU sort.

Common Options


-b, --ignore-leading-blanks

Ignore leading spaces and tabs.


-c, --check

Check whether files are already sorted, and if so, produce no output.


-d, --dictionary-order

Sort in dictionary order (ignore punctuation).


-f, --ignore-case

"Fold"; ignore uppercase/lowercase differences.


-i, --ignore-nonprinting

Ignore nonprinting characters (those outside ASCII range 040-176).


-k fieldspec, --key=fieldspec

Specify significance of input fields for sorting. See the fuller description below.


-m, --merge

Merge sorted input files.


-M, --month-sort

Compare first three characters as abbreviations for month names (Jan < Feb, etc.).


-n, --numeric-sort

Sort in arithmetic (numerical) order.


-o file, --output=file

Put output in file.


-r, --reverse

Reverse the order of the sort.


-tc, --field-separator=c

Fields are separated with c (default is any whitespace).


-T dir, --temporary-directory=dir

Use dir for temporary files.


-u, --unique

Identical lines in input file appear only one (unique) time in output.


+ n [- m]

Skip n fields before sorting, and sort up to field position m. If m is missing, sort to end of line. Positions take the form a.b, which means character b of field a. If .b is missing, sort at the first character of the field. Counting starts at zero. Fields may have optional trailing modifiers, as in the -k option. Note: This method of describing fields is considered obsolete. Use -k instead.

Solaris Options


-S kmem

Adjust the amount of swap-based memory (in kilobytes) sort uses. Trailing suffixes of b, k, m, g, t, and %, allow specification of memory in bytes, kilobytes, megabytes, gigabytes and terabytes, or as a percentage of physical memory, respectively.


-y [ kmem]

Adjust the amount of memory (in kilobytes) sort uses. If kmem is not specified, allocate the maximum memory. Obsolete: use -S instead.


-z recsz

Provide the maximum number of bytes for any one line in the file. This option prevents abnormal termination of sort in certain cases. Solaris sort accepts but otherwise ignores this option.

Gnu/Linux and Mac OS X Option


-s, --stable

Provide a stable sort, which preserves the order of input records that otherwise compare equal.

Gnu/Linux Options


-g, --general-numeric-sort

Sort in general numeric order.


-S size, --buffer-size=size

Like the Solaris -S option. Besides the suffixes listed there, GNU sort allows P, E, Z, and Y, each of which increases the possible amount by even more orders of magnitude.


-z, --zero-terminated

End lines with a zero byte, not with a newline.

Field Specifications for -k

A fieldspec has the form fieldstart [type ][,fieldend [type ]].


fieldstart

A field number and optional starting character of the form fnum [.schar]. fnum is the field number, starting from 1. schar, if present, is the starting character within the field, also counting from 1.


fieldend

A field number and optional ending character of the form fnum [.echar ]. fnum is the field number, starting from 1. echar, if present, is the last significant character within the field, also counting from 1.


type

A modifier, one of the letters b, d, f, i, M, n, or r. The effect is the same as the corresponding option, except that the b modifier only applies to the fields, not the whole line.

Examples

List files by decreasing number of lines:

     wc -l * | sort -rn

Alphabetize a list of words, remove duplicates, and print the frequency of each word:

     sort -fd wordlist | uniq -c

Sort the password file numerically by the third field (user ID):

     sort -k 3n -t: /etc/passwd

Find the top 20 disk hogs on a system:

     cd /home; du -sk * | sort -nr | head -n 20

spell

     spell [options] [files]

Compare the words of one or more named files with the system dictionary and report all misspelled words. System files for spell reside in /usr/lib/spell.

Solaris and commercial Unix systems supply the original Unix version of spell. Mac OS X does not have spell; however, you can download either ispell or aspell and use them instead. GNU/Linux supplies both aspell and ispell, but not necessarily a spell command.

Program

URL(s)

aspell

http://aspell.net/

http://www.gnu.org/software/aspell

ispell

http://www.gnu.org/software/ispell


At least one major GNU/Linux system uses the following shell script to emulate spell:

     #!/bin/sh     # aspell -l mimicks the standard unix spell program, roughly.     cat "$@" | aspell -l --mode=none | sort -u

See also Classic Shell Scripting, cited in the Bibliography, which devotes an entire chapter to the topic of spell checking, including improvements to the previously shown script.

Solaris Options


-b

Check for British spelling.


-i

Ignore files included with the nroff or troff .so request. No effect if deroff is unavailable.


-l

Follow all included files (files named in .so or .nx requests); default is to ignore filenames that begin with /usr/lib.


-v

Include words that are derived from the dictionary list but are not literal entries.


-x

Show every possible word stem (on standard error).


+ wordlist

Use the sorted wordlist file as a local dictionary to add to the system dictionary; words in wordlist are not treated as misspelled.

Example

Run the first pass of spell :

     spell file1 file2 > jargon

After editing the jargon file, use it as a list of special terms. The second pass of spell produces genuine misspellings:

     spell +jargon file[12] > typos        Solaris spell

split

     split [options] [infile] [outfile]

Split infile into several files of equal length. infile remains unchanged, and the results are written to outfileaa, outfileab, etc. (default is xaa, xab, etc.). If infile is - (or missing), standard input is read. See also csplit.

Common Options


-n, -l n, --lines=n

Split infile into files, each n lines long (default is 1000).


-a slen, --suffix-length=slen

Use slen characters for the filename suffix. Default is 2.


-b n[ m], --bytes=n[ m]

Split into pieces of size n bytes. An optional multiplier m may be supplied: k for kilobytes and m for megabytes. GNU/Linux allows b for 512-byte blocks. Mutually exclusive with -l.

GNU/Linux Options


-C bytes[ m], --line-bytes=bytes[ m]

Put a maximum of bytes into file; insist on adding complete lines. m is a multiplier: b for 512, k for 1024, and m for one megabyte.


-d, --numeric-suffixes

Use numeric file suffixes instead of alphabetic ones.


--verbose

Print a message for each output file.

Examples

Break bigfile into 1000-line segments:

     split bigfile

Join four files, then split them into ten-line files named new.aa, new.ab, etc. Note that without the -, new. would be treated as a nonexistent input file:

     cat list[1-4] | split -l 10 - new.

ssh

     ssh [options] hostname [command]     slogin [options] hostname [command]

Securely log a user into a remote system and run commands on that system. The version of ssh described here is the OpenSSH client. ssh can use either Version 1 (SSH1) or Version 2 (SSH2) of the SSH protocol. SSH2 is preferable, as it provides better encryption methods and greater connection integrity. The hostname can be specified either as hostname or as user@hostname. If a command is specified, the user is authenticated, the command is executed, and the connection is closed. Otherwise, a terminal session is opened on the remote system. See the "Escape characters" section later in this entry for functions that can be supported through an escape character. The default escape character is a tilde (~). The exit status returned from ssh is the exit status from the remote system or 255 if there was an error. Interestingly enough, Solaris, GNU/Linux, and Mac OS X all use OpenSSH . See also scp, sftp, and SSH, The Secure Shell, cited in the Bibliography.

On GNU/Linux and Mac OS X, slogin is a symbolic link to ssh. It is meant to replace the original BSD rlogin command.

URL: http://www.openssh.org.

Options


-1

Try only SSH1.


-2

Try only SSH2.


-4

Use only IPv4 addresses.


-6

Use only IPv6 addresses.


-a

Disable forwarding of the authentication agent connection.


-A

Allow forwarding of the authentication agent connection. Can also be specified on a per-host basis in a configuration file.


-b bind_address

Specify the interface to transmit from when there are multiple available interfaces or aliased addresses.


-c blowfish |3des |des |ciphers

Select the cipher for encrypting the session. The default is 3des. For SSH2, a comma-separated list of ciphers can also be specified, with the ciphers listed in order of preference. des is supported only for legacy SSH1 compatibility and otherwise should not be used.


-C

Enable compression. Useful mainly for slow connections. The default compression level can be set on a per-host basis in the configuration file with the CompressionLevel option.


-D port

Enable dynamic application-level port forwarding using port on the local side. Can be specified in the configuration file. Only a privileged user can forward privileged ports.


-e char|^ char|none

Set the escape character (default ~). The escape character must be the first character on a line. If none is specified, disable the use of an escape character.


-f

Run interactively for user authentication, then go into background mode for command execution. Implies -n.


-F configfile

Specify a per-user configuration file (default is $HOME/.ssh/config).


-g

Allow remote hosts to connect to local forwarded ports.


-i idfile

Use idfile to read identity (private key) for RSA or DSA authentication. Default is $HOME/.ssh/id_rsa or $HOME/.ssh/id_dsa for SSH2, or $HOME/.ssh/identity for SSH1. You can specify more than one -i option on the command line or in the configuration file.


-I device

Specify a smartcard device from which to get the user's private RSA key.


-k

Disable Kerberos ticket and AFS token forwarding. Can be set on a per-host basis in the configuration file.


-l user

Log in as user on the remote system. Can be specified on a per-host basis in the configuration file.


-L port:host:hostport

Forward port on the local host to the specified remote host and port. Can be specified in the configuration file. Only a privileged user can forward privileged ports. For IPv6, an alternative syntax is port/host/hostport.


-m macspec

For SSH2, the contents of macspec specify message authentication code (MAC) algorithms to use. macspec is a comma-separated list of algorithms in order of preference.


-n

Get standard input as a redirection from /dev/null. Used to prevent reading from standard input, which is required when running ssh in the background. Useful for running X programs on a remote host.


-N

Do not execute a remote command. Useful with SSH2 for port forwarding.


-o option

Specify options in configuration-file format. Useful for specifying options that have no command-line equivalent.


-p port

Specify the port on the remote host to which ssh is to connect. Can be specified on a per-host basis in the configuration file.


-q

Run quietly, suppressing warnings and error messages.


-R port:host:hostport

Forward port on the remote host to the local host:hostport. Can be specified in the configuration file. You can forward privileged ports only if you are logged in as root on the remote host. For IPv6, an alternative syntax is port/host/hostport.


-s

For SSH2, request invocation of a subsystem on the remote host to be used for another application such as sftp. The desired subsystem is specified as the remote command.


-t

Force pseudo-tty allocation. Multiple -t options can be specified to force tty allocation even when ssh has no local tty.


-T

Disable pseudo-tty allocation.


-v

Verbose mode. Useful for debugging. Specify multiple -v options to increase verbosity.


-V

Display just the version number. GNU/Linux and Mac OS X only.


-x

Disable X11 forwarding.


-X

Enable X11 forwarding. Can be specified on a per-host basis in the configuration file.

Escape characters


~.

Disconnect.


~~

Send a single ~.


~#

List forwarded connections.


~&

Run ssh in the background at logout, while waiting for a forwarded connection or X11 sessions to terminate.


~?

Display the available escape characters.


~C

Open a command line. Useful for adding port forwardings when using the -L and -R options.


~R

Request rekeying of the connection. Useful only for SSH2 and if the peer supports it.


~^Z

Suspend the connection.

ssh-add

     ssh-add [options] [files]     ssh-add -e|-s reader

Add RSA or DSA identities to the authentication agent (see ssh-agent), which must be running. With no arguments specified, add the files $HOME/.ssh/id_rsa, $HOME/.ssh/id_dsa, and $HOME/.ssh/identity. If any files are specified, add those instead, prompting for a passphrase if required.

Options


-c

Confirm that an added identity should be used for authentication. The confirmation is done by the program named in the SSH_ASKPASS environment variable. GNU/Linux and Mac OS X only.


-d

Remove an identity from the agent instead of adding one.


-D

Delete all identities from the agent.


-e reader

Remove key in specified smartcard reader.


-l

List fingerprints of all identities known to the agent.


-L

List public key parameters of all identities known to the agent.


-s

Add key in smartcard reader.


-t life

Set maximum lifetime when adding identities to an agent. The value of life can be in seconds or another time format specified in sshd.


-x

Lock the agent with a password.


-X

Unlock the agent.

ssh-agent

     ssh-agent [options] [command [arguments]]

Hold private keys used for public key authentication. ssh-agent is usually executed at the beginning of an X or login session; then all other windows or programs given as command are run as clients of ssh-agent. When a command is specified, the command and any arguments are executed. The agent dies when the command completes. Use ssh-add to add keys to the agent. Operations that require a private key are performed by the agent, which returns the results to the requestor.

Options


-a bind_addr

Bind the agent to the socket bind_addr (default is /tmp/ssh-nnnnnnnn/agent, where nnnnnnnn is a generated number).


-c

Write csh commands to standard output. This is the default if the environment variable SHELL looks like a csh-type shell.


-d

Debug mode.


-k

Kill the current agent.


-s

Write Bourne shell commands to standard output. This is the default if the environment variable SHELL does not look like a csh-type command.


-t life

Set maximum lifetime when adding identities to an agent. The value of life can be in seconds or another time format specified in sshd. GNU/Linux and Mac OS X only.

ssh-keygen

     ssh-keygen [options]

Generate, manage, and convert authentication keys for ssh.

Common Options


-b bits

Specify the number of bits in the key. The minimum is 512 and the default is 1024.


-B

Show the bubblebabble digest (a digest represented as a string that looks like real words) for the private or public key file specified with -f.


-c

Change the comment in the private and public key files (for RSA1 keys only).


-C comment

Specify the new comment.


-e

Read an OpenSSH private or public key file and write it in SECSH Public Key File Format to standard output for exporting to a commercial SSH.


-f file

Specify the filename of the key file.


-i

Read an SSH2-compatible unencrypted private or public key file and write an OpenSSH-compatible key to standard output. Used to import keys from a commercial SSH.


-l

Show fingerprint of public or private RSA1 key file specified with -f.


-N passphrase

Specify the new passphrase.


-p

Change the passphrase for a private key file. Prompt for the file, the old passphrase, and twice for the new passphrase.


-P passphrase

Specify the old passphrase.


-q

Operate in quiet mode.


-t type

Specify the type of key to create. Possible values of type are rsa1 for SSH1, and rsa or dsa for SSH2.


-y

Read a private OpenSSH-format file and print a public key to standard output.

GNU/Linux and Mac OS X Options


-D reader

Download the RSA public key from the smartcard in reader.


-U reader

Upload an existing RSA private key to the smartcard in reader.

Mac OS X Options


-a trials

Make trials primatlity tests for DH-GEX candidates with -T.


-g

Use generic DNS record format.


-G file

Produce candidate primes for DH-GEX to file.


-M mem

Use mem megabytes when generating candidate moduli for DH-GEX.


-r hostname

Print DNS resource records using hostname.


-S start

Start at start (in hexadecimal) when generating candidate moduli for DH-GEX.


-T file

Test DH group exchange candidate primes for safety. Such primes are generated with -G.


-v

Be verbose. Helpful for debugging moduli generation. May be repeated up to three times to increase verbosity.


-W generator

Use generator when testing candidate moduli for DH-GEX.

strings

     strings [options] files

Search object or binary files for sequences of four or more printable characters that end with a newline or null. See also od.

Common Options


- n, -n n, --bytes=n

Minimum string length is n (default is 4).


-, -a, --all

Search entire file, not just the initialized data portion of object files.


-o

Display the string's offset position before the string. Solaris and Mac OS X: same as -t d. GNU/Linux: same as -t o.


-t format, --radix=format

Specify how to print string offsets. format is one of d, o, or x for decimal, octal, or hexadecimal, respectively.

GNU/Linux Options


-e encoding, --encoding=encoding

Specify the character encoding of the strings to be found. Possible values are:

b

16-bit big-endian

B

32-bit big-endian

l

16-bit little-endian

L

32-bit little-endian

s

Single-byte character, such as ASCII, ISO-8859, etc. (the default)



--target=format

Specify an alternative object code format to the system default. Any valid BFD target name may be used for format.

strip

     strip [options] files

Remove information from ELF object files or archive files, thereby reducing file sizes and freeing disk space. On Solaris, strip is in /usr/ccs/bin.

Like the loader ld, this program has diverged across time and platforms, to the point where it's not worthwhile to provide an option list. See the manpage for your local system.

stty

     stty [options] [modes]

Set terminal I/O options for the current device. Without options, stty reports the terminal settings, where a ^ indicates the Control key, and ^' indicates a null value. Most modes can be switched using an optional preceding - (shown in brackets). The corresponding description is also shown in brackets. As a privileged user, you can set or read settings from another device using the syntax:

     stty [options] [modes] < device

stty is one of the most complicated Unix commands. The complexity stems from the need to deal with a large range of conflicting, incompatible, and nonstandardized terminal devices everything from printing teletypes to CRTs to pseudo-terminals for windowing systems. Only a few of the options are really needed for day-to-day use. stty sane is a particularly valuable one to remember.

Solaris provides additional hardware flow control modes and clock modes; see the stty(1) manpage should you find that you need these features.

Common Options


-a, --all

Report all option settings.


-g, --save

Report current settings.

GNU/Linux Options


-F device, --file=device

Read or change setting of device instead of the current terminal.

Mac OS X Options


-e

Print information in BSD stty everything format.


-f device

Read or change setting of device instead of the current terminal.

Many but not all of the following features are shared among all the systems. For brevity, Solaris-only features are marked with an S, GNU/Linux-only features are marked with an L, and Mac OS X-only features are marked with an M. Items without any mark work on all the systems.

Control Modes


0

Hang up connection (set the baud rate to zero).


n

Set terminal baud rate to n (e.g., 19200).


[-]clocal

[Enable] disable modem control.


[-]cread

[Disable] enable the receiver.


[-]crtscts

[Disable] enable output hardware flow control using RTS/CTS.


[-]crtsxoff

[Disable] enable input hardware flow control using RTS. S.


cs n

Select character size in bits (5 8).


[-]cstopb

[One] two stop bits per character.


defeucw

Set the width in bytes per character and screen display columns per character, for EUC (Extended Unix Code) characters. S.


[-]hup

[Do not] hang up connection on last close.


[-]hupcl

Same as [-]hup.


ispeed n

Set terminal input baud rate to n.


ospeed n

Set terminal output baud rate to n.


[-]parenb

[Disable] enable parity generation and detection.


[-]parext

[Disable] enable extended parity generation and detection for mark and space parity. S.


[-]parodd

Use [even] odd parity.

Input Modes


[-]brkint

[Do not] signal INTR on break.


[-]icrnl

[Do not] map carriage return (^M) to newline (^J) on input.


[-]ignbrk

[Do not] ignore break on input.


[-]igncr

[Do not] ignore carriage return on input.


[-]ignpar

[Do not] ignore parity errors.


[-]imaxbel

[Do not] echo BEL when input line is too long.


[-]inlcr

[Do not] map newline to carriage return on input.


[-]inpck

[Disable] enable input parity checking.


[-]istrip

[Do not] strip input characters to 7 bits.


[-]iuclc

[Do not] map uppercase to lowercase on input. S, L.


[-]ixany

Allow [only XON] any character to restart output.


[-]ixoff

[Do not] send START/STOP characters when the queue is nearly empty/full.


[-]ixon

[Disable] enable START/STOP output control.


[-]parmrk

[Do not] mark parity errors.


[-]tandem

Same as [-]ixoff. L, M.

Output Modes


bs n

Select style of delay for backspaces (n = 0 or 1). S, L.


cr n

Select style of delay for carriage returns (0 3). L.


ff n

Select style of delay for formfeeds (n = 0 or 1). S, L.


nl n

Select style of delay for linefeeds (n = 0 or 1). S, L.


[-]ocrnl

[Do not] map carriage return to newline on output.


[-]ofdel

Set fill character to [NULL] DEL. S, L.


[-]ofill

Delay output with [timing] fill characters. S, L.


[-]olcuc

[Do not] map lowercase to uppercase on output. S, L.


[-]onlcr

[Do not] map newline to carriage return-newline on output.


[-]onlret

[Do not] perform carriage return after newline.


[-]onocr

[Do not] output carriage returns at column zero.


[-]opost

[Do not] postprocess output; ignore all other output modes.


[-]oxtabs

[Do not] expand tabs to spaces. M.


tab n

Select style of delay for horizontal tabs (0 3). L.


vt n

Select style of delay for vertical tabs (n = 0 or 1). S, L.

Local Modes


[-]altwerase

[Do not] Use an alternate algorithm for processing the "word erase" character. M.


[-]cbreak

Opposite of [-]icanon. L, M.


[-]ctlecho

Same as [-]echoctl. L, M.


[-]crterase

Same as [-]echoe. L, M.


[-]crtkill

Same as [-]echoke. L, M.


[-]echo

[Do not] echo every character typed.


[-]echoctl

[Do not] echo control characters as ^char, DEL as ^?.


[-]echoe

[Do not] echo ERASE character as BS-space-BS string.


[-]echok

[Do not] echo newline after KILL character.


[-]echoke

[Do not] BS-SP-BS erase entire line on line kill.


[-]echonl

[Do not] echo newline (^J).


[-]echoprt

[Do not] echo erase character as character is "erased."


[-]flusho

Output is [not] being flushed. S, M.


[-]icanon

[Disable] enable canonical input (ERASE and KILL processing).


[-]iexten

[Disable] enable extended functions for input data.


[-]isig

[Disable] enable checking of characters against INTR, QUIT, and SWITCH.


[-]lfkc

Same as [-]echok. Obsolete. S.


[-]mdmbuf

[Do not] flow control output based on the state of Carrier Detect. M.


[-]noflsh

[Enable] disable flush after INTR, QUIT, or SWITCH.


[-]pendin

[Do not] retype pending input at next read or input character. S, M.


[-]prterase

Same as [-]echoprt. L, M.


[-]stappl

[Line] application mode on a synchronous line. S.


[-]stflush

[Disable] enable flush on synchronous line. S.


[-]stwrap

[Enable] disable truncation on synchronous line. S.


[-]tostop

[Do not] send SIGTTOU when background processes write to the terminal.


[-]xcase

[Do not] change case on local output. S, L.

Control Assignments


ctrl-char c

Set control character to c. ctrl-char is:

Common

dsusp, eof, eol, eol2, erase, intr, kill, lnext, quit, rprnt, start, stop, susp, werase

Solaris

ctab, discard, reprint

GNU/Linux

swtch

Mac OS X

brk (same as eol), erase2, flush (same as discard), reprint, status



line i

Set line discipline to i (1 126). L.


min n

With -icanon, n is the minimum number of characters that will satisfy the read system call until the timeout set with time expires.


time n

With -icanon, n is the number of tenths of seconds to wait before a read system call times out. If the minimum number of characters set with min has been read, the read can return before the timeout expires.

Combination Modes


all

Like stty -a, but print information in the traditional BSD columnar format. M.


async

Set normal asynchronous communications. S.


cooked

Same as -raw.


[-]crt

[Disable] Enable echoe echok echoke. L, M.


[-]crtbs

Same as [-]echoe. M.


dec

Same as echoe echoctl echoke -ixany intr ^C erase 0177 kill ^U. L, M.


[-]decctlq

Converse of [-]ixany. L, M.


ek

Reset ERASE and KILL characters to system defaults.


[-]evenp

Same as [-]parenb and cs7[8].


everything

Same as stty all. M.


[-]extproc

Indicate that the terminal hardware or the remote side of a pty is [not] doing some of the terminal processing. M.


[-]kerninfo

[Disable] Enable the system's response to the status character, usually CTRL-T. M.


[-]lcase

[Un] set xcase, iuclc, and olcuc. S, L.


[-]litout

Converse of [-]opost. L, M.


[-]LCASE

Same as [-]lcase. S, L.


[-]markp

[Disable] enable parenb, parodd, and parext, and set cs7[8]. S.


new

Same as stty tty. M.


[-]newcrt

Same as [-]crt. M.


[-]nl

[Un] set icrnl and onlcr. -nl also unsets inlcr, igncr, ocrnl, and onlret.


[-]oddp

Same as [-]parenb, [-]parodd, and cs7[8].


old

Same as stty tty. M.


[-]parity

Same as [-]parenb and cs7[8].


[-]pass8

Converse of [-]parity. L, M.


[-]raw

[Disable] enable raw input and output (no ERASE, KILL, INTR, QUIT, EOT, SWITCH, or output postprocessing).


sane

Reset all modes to reasonable values.


size

Print the terminal's size in rows and columns. L, M.


speed

Print the terminal's speed (baud rate). L, M.


[-]spacep

[Disable] enable parenb and parext, and set cs7[8]. S.


[-]tabs

[Expand to spaces] preserve output tabs.


term

Set all modes suitable for terminal type term (tty33, tty37, vt05, tn300, ti700, or tek). (These predefined names are all so obsolete as to be useless.) S.


tty

Use the standard line discipline. M.

Window size


columns n

Set size to n columns. Can also be given as cols.


rows n

Set size to n rows.


xpixels n

Set size to n pixels across. S.


ypixels n

Set size to n pixels up and down. S.

su

     su [option] [user] [shell_args]

Create a shell with the effective user ID of another user (that is, login as user). If no user is specified, create a shell for a privileged user (that is, become a superuser). Enter EOF to terminate. You can run the shell with particular options by passing them as shell_args (e.g., if the shell runs sh, you can specify -c command to execute command via sh, or -r to create a restricted shell).

su will inherit your environment settings. Administrators wishing to switch to a user's setup (perhaps to help them solve a problem) may wish to consider using this sequence:

     me$ su                     Switch to root     Password:                 Enter root password     # su -  user                Switch to other user     user$

The sudo program is worth installing if your system doesn't have it. See http://www.sudo.ws/ and/or http://www.courtesan.com/sudo.

Common Option


-

Go through the entire login sequence (i.e., change to user's environment).

GNU/Linux and Mac OS X Options


-c command, --command=command

Run a single command (by way of sh -c).


-f, --fast

Pass -f on to csh or tcsh.


-l, --login

Same as su -.


-m, --preserve-environment

Preserve the environment.

GNU/Linux Options


-p

Same as -m.


-s shell, --shell=shell

Use shell if shell is listed in /etc/shells.

tail

     tail [options] [file]

Print the last 10 lines of the named file. Use only one of -f or -r.

The GNU/Linux and Mac OS X versions can process multiple files. In that case, the output includes a header at the beginning of each file:

     =  =>filename<=  =

Historic Options

The syntaxes shown here are the historic usage. Currently all systems continue to accept them, but the -c and -n options are preferred.


-n[ k]

Begin printing at n th item from end of file. k specifies the item to count: l (lines, the default), b (blocks), or c (characters, i.e., bytes).


-k

Same as previous, but use the default count of 10.


+ n[ k]

Like -n, but start at n th item from beginning of file.


+ k

Like -k, but count from beginning of file.

Common Options


-c count, --bytes=count

With a leading + on count, start count bytes from the front of the file. With a leading - or no sign, start from the end of the file.


-f [ follow_spec], --follow[= follow_spec]

Don't quit at the end of file; "follow" file as it grows. End with an INTR (usually ^C).

Only GNU/Linux allows a follow_spec. If the follow_spec is descriptor, tail follows the open file descriptor. This shows the original file, even if it is renamed or removed, and is the command's original, default behavior. If follow_spec is name, then tail periodically reopens the file by name. This is useful in cases where filenames change, such as rotated log files.


-n count, --lines=count

With a leading + on count, start count lines from the front of the file. With a leading - or no sign, start from the end of the file.

Solaris and Mac OS X Option


-r

Copy lines in reverse order.

GNU/Linux Options


-F

Identical to --follow=name --retry.


--max-unchanged-stats=num

Used with --follow=name to reopen a file whose size hasn't changed after num iterations (default 5), to see if it has been unlinked or renamed (as with rotated log files).


--pid=pid

Used with -f to end when process ID pid dies.


-q, --quiet, --silent

Suppress filename headers.


--retry

With -f, keep trying to open a file even if it isn't accessible when tail starts or if it becomes inaccessible later.


-s sec, --sleep-interval=sec

With -f, sleep approximately sec seconds between iterations. Default is 1 second.


-v, --verbose

With multiple files, always output the filename headers.

Mac OS X Options


-b count

With a leading + on count, start count blocks (512-byte units) from the front of the file. With a leading - or no sign, start from the end of the file.


-F

Like the GNU/Linux --follow=name.

Examples

Show the last 20 lines containing instances of <title>:

     grep '<title>' file | tail -n 20

Continually track the latest system messages (under GNU/Linux):

     tail -f /var/log/messages

Show the last 10 characters of variable name:

     echo "$name" | tail -c

Reverse all lines in list :

     tail -r list

talk

     talk user [@hostname] [tty]

Exchange typed communication with another user who is on the local machine or on machine hostname. talk might be useful when you're logged in via modem and need something quickly, making it inconvenient to telephone or send email. talk splits your screen into two windows. When connection is established, you type in the top half while user's typing appears in the bottom half. Type ^L to redraw the screen and ^C (or interrupt) to exit. If user is logged in more than once, use tty to specify the terminal line. The user needs to have used mesg y.

Notes

  • There are different versions of talk that use different protocols; interoperability across different Unix systems is very limited.

  • talk is also not very useful if the remote user you are "calling" is using a windowing environment, since there is no way for you to know which tty to use to get their attention. The connection request could easily show up in an iconified window! Even if you know the remote tty, the called party must have done a mesg y to accept the request, and the called system must allow incoming talk connections. All in all, this command is not as useful as it once was.

tar

     tar [options] [files]

Copy files to or restore files from tape (tape archive). If any files are directories, tar acts on the entire subtree. (See also cpio and pax.)

Options are supplied as one group, with any arguments placed afterward in corresponding order. Originally, tar did not even accept a leading - on its options. Although the Solaris version allows one, it does not require it. On many other Unix systems, you may use conventional option notation, with each option preceded by a dash and separated from the other options with whitespace. Some systems actually require the use of separate options. Check your local documentation for the final word.

GNU/Linux and Mac OS X both use the GNU version of tar which accepts all the common options, and also has many options of its own.

Notes

For the following reasons, tar is best used as a way to exchange file or source code archives over a network. A system administrator performing system backups is advised to use the vendor-supplied backup program (typically called dump or backup; see your local documentation) for backups instead of tar. (Many of these same points apply to cpio and to pax as well.)

  • Most Unix versions of tar preserve the leading / from an absolute filename in the archive. This makes it difficult or impossible to extract the files on a different system.

  • The tar archive format was designed when Unix file and directory names were short (14 characters maximum). Modern Unix systems allow individual filenames to be up to 255 characters in length, but the tar archive header has a limit of 100 characters for the entire pathname. This makes it difficult or impossible in practice to archive a typical Unix filesystem.

  • In general, Unix versions of tar cannot recover from data errors, which are particularly common with tapes. An early tape error can render an entire tar tape useless.

  • While tar does checksum the header information describing each archived file, it does not checksum the actual data blocks. Thus, if a data block becomes corrupted on a tape, tar will never notice.

The GNU version of tar has extensions to get around many of these problems, at the cost of portability of the archive format to non-GNU versions. Source code can be obtained from the Free Software Foundation (see http://www.gnu.org/software/tar).

Common Control Option


-C dir files, --directory=dir files

Change directory to dir before adding files to the archive. Use relative pathnames. This option makes it possible to archive files that don't share a common ancestor directory.

Solaris Control Options


-I file

Read a list of filenames to be archived, one filename per line, from file. Useful when there are too many files to name on the command line.


-X file

Exclude files. The corresponding file argument is read for a list of relative pathnames, one per line, of files that should not be archived. This option may be provided multiple times with multiple files. Filenames that appear here are excluded even if the same name was provided in a file used with -I.

GNU tar Control Options


-T file, --files-from=file

Read a list of filenames to be archived, one filename per line, from file. Useful when there are too many files to name on the command line.


-X file, --exclude-from=file

Exclude files. The corresponding file argument is read for a list of relative pathnames, one per line, of files that should not be archived. Each line may be a shell wildcard pattern. This option may be provided multiple times with multiple files.

Common Function Options (Choose One)


-c, --create

Create a new archive.


-r, --append

Append files to archive.


-t, --list

Table of contents. Print the names of files if they are stored on the archive (if files not specified, print names of all files).


-u, --update

Update. Add files if not in archive or if modified.


-x, --extract, --get

Extract files from archive (if files not specified, extract all files).

GNU tar Function Options (Choose One)


-A, --catenate, --concatenate

Concatenate a second tar file to the end of the first.


-d, --diff, --compare

Compare the files stored in tarfile with other-files. Report any differences: missing files, different sizes, different file attributes (such as permissions or modification time).


--delete

Delete from the archive. This option cannot be used with magnetic tape.

Common Options


n[ c]

Select tape drive n and use speed c. n is 0 7 (default is 0); c is l (low), h (high), or m (medium, the default). Used to modify arch. (These are highly system-specific and nonportable: it is much better to always just specify the arch explicitly with -f.)


-b n, --blocking-factor=n

Use blocking factor n (default is 1; maximum is 20). Different Unix systems often allow larger blocking factors.


-B, --read-full-records

Continue reading until logical blocks are full. For use across Ethernet connections with rsh or ssh. On some systems, enabled by default when reading standard input.


-f arch, --file=arch

Store files in or extract files from archive arch; arch is usually a device name (default varies from system to system). If arch is -, standard input or output is used as appropriate (e.g., when piping a tar archive to a remote host). GNU tar allows remote tape drives, of the form host:device.


-h, --dereference

Follow symbolic links, archiving the files they point to, not the links themselves.


-m, --touch

Do not restore file modification times; update them to the time of extraction.


-p, --same-permissions, --preserve-permissions

Preserve permissions of extracted files. On Solaris, ACLs are restored if recorded in the archive and are added to the archive when used with -c.


-v, --verbose

Print function letter (x for extraction or a for archive) and name of files. With -t, print a listing similar to that of ls -l.


-w, --interactive, --confirmation

Wait for user confirmation (y) before taking any actions.

Solaris Options


-D

Warn about changes in data files instead of treating them as fatal errors; for example, if a file's size changes while it's being archived.


-e

Exit immediately upon unexpected errors.


-E

Use an extended header that allows longer filenames, larger files, and other extensions. Not portable.


-F, -FF

With F, do not archive SCCS and RCS directories. With FF, also exclude files named a.out, core, errs, and all .o files.


-i

Ignore directory checksum errors.


-k size

Specify the archive size in kilobytes. Archives that are larger than size are split across volumes. Useful for fixed-size media, such as floppy disks.


-l

Print error messages about links that can't be found.


-n

Archive is not a tape device. This allows tar to seek, instead of doing sequential reads, which is faster.


-o

Change ownership of extracted files to that of user running program. This is the default for nonprivileged users.


-P

Do not add a trailing / to directory names in the archive.


-q

Quit after extracting the first occurrence of the named file. Normally tar continues reading the archive.


-@

Add Solaris extended file attributes to the archive upon archive creation, or extract them from the archive if extracting. They may only be extracted as part of extracting a file; it is not possible to extract just the extended attributes.

GNU tar Options


--anchored

Exclude patterns must match the start of the filename (the default).


--atime-preserve

Preserve original access time on extracted files.


--backup[= type]

Instead of overwriting files upon extraction, back them up. If no backup type is specified, a simple backup is made with ~ as the suffix. (See also --suffix.) The possible values of type are:

t, numbered

Make numbered backups.

nil, existing

Make numbered backups if there are already numbered backups, otherwise make simple backups.

never, simple

Always make simple backups.



--check-links

When creating an archive, if a file has multiple hard links, and not all the file's links were written to the archive, output a warning message.


--checkpoint

List directory names encountered.


--exclude=pattern

Remove files matching pattern from any list of files.


--force-local

Interpret filenames in the form hostname:filename as local files.


--format=type

Create a type format archive. Valid values are gnu, oldgnu, posix, ustar, and v7.


-F script, --info-script=script


--new-volume-script=script

Implies -M (multiple archive files). Run script at the end of each file.


-g file, --listed-incremental=file

Create new-style incremental backup.


--group=group

Use group as the group for files added to the archive.


-G, --incremental

Create old-style incremental backup.


-i, --ignore-zeros

Ignore zero-sized blocks (i.e., EOFs).


--ignore-case

Ignore case when excluding files.


--ignore-failed-read

Ignore unreadable files to be archived. Default behavior is to exit when encountering these.


--index-file=file

Send verbose output to file instead of to standard output.


-j, --bzip2

Compress files with bzip2 before archiving them, or uncompress them with bunzip2 before extracting them.


-k, --keep-old-files

When extracting files, do not overwrite files with identical names. Instead, print an error message.


-K file, --starting-file=file

Begin tar operation at file in archive.


--keep-newer-files

If a file being extracted is newer than the one in archive, do not replace it.


-l, --one-file-system

Do not archive files from other filesystems. Note: in the future, the meaning of -l will change to --check-links.


-L length, --tape-length=length

Write a maximum of length x 1024 bytes to each tape.


--mode=permissions

Use permissions when adding files to an archive. The permissions are specified the same way as for the chmod command.


-M, --multivolume

Expect archive to be multivolume. With -c, create such an archive.


--newer-mtime=date

Add only files whose contents have changed since date to the archive.


--no-anchored

Exclude patterns may match after any slash.


--no-ignore-case

Do not ignore case when excluding files.


--no-recursion

Do not move recursively through directories.


--no-same-owner

When extracting, create files with yourself as owner.


--no-same-permissions

Do not extract permissions information when extracting files from the archive. This is the default for users, and therefore affects only the superuser.


--no-wildcards

Don't use wildcards when excluding files; treat patterns as strings.


--no-wildcards-match-slash

Wildcards do not match / when excluding files.


--null

Allow filenames to be null-terminated with -T. Override -C.


--numeric-owner

Use the numeric owner and group IDs rather than the names.


-N date, --newer=date, --after-date=date

Ignore files older than date.


-o

If creating an archive, same as --old-archive. If extracting, same as --no-same-owner.


--occurrence[= num]

Process only the num th occurrence of each named file. For use with --delete, --diff, --extract, or --list.


--old-archive, --portability

Create old-style archive in Unix V7 rather than POSIX format.


--overwrite

Overwrite existing files and directory metadata when extracting from archive.


--overwrite-dir

Overwrite existing directory metadata when extracting from archive.


--owner=owner

Set owner as the owner of extracted files instead of the original owner. owner is first assumed to be a username, then, if there is no match, a numeric user ID.


-O, --to-stdout

Print extracted files to standard output.


--pax-option=keywords

For use with posix format archives, process the keywords appropriately. See the online Info manual for the (complicated) details.


--posix

Create a POSIX-compliant archive.


--preserve

Equivalent to invoking both the -p and -s options.


-P, --absolute-names

Do not remove initial slashes (/) from input filenames.


--record-size=size

Treat each record as having size bytes, where size is a multiple of 512.


--recursion

Move recursively through directories.


--recursive-unlink

Remove existing directory hierarchies before extracting directories with the same name.


--remove-files

Remove originals after inclusion in archive.


--rmt-command=command

Use command on a remote host to perform remote file operations instead of /usr/local/libexec/rmt (or whatever was configured into tar when it was built).


--rsh-command=command

Do not connect to remote host with rsh; instead, use command.


-R, --block-number

Display archive's block number in messages.


-s, --same-order, --preserve-order

When extracting, sort filenames to correspond to the order in the archive.


--same-owner

When extracting, create files with the same ownership as the originals.


--show-defaults

Show the default options and exit successfully. For use in shell scripts.


--show-omitted-dirs

List directories being omitted when operating on an archive.


--strip-path=count

Strip count leading components off of archived pathnames before extraction.


--suffix=suffix

Use suffix instead of the default ~ when creating a backup file.


-S, --sparse

Treat sparse files more efficiently when adding to archive.


--totals

Print byte totals.


--use-compress-program=program

Compress archived files with program, or uncompress extracted files with program.


--utc

Display file modification times in UTC instead of in local time.


-U, --unlink-first

Remove each existing file from the filesystem before extracting from the archive.


-v, --verbose

Verbose. Print filenames as they are added or extracted.


--volno-file=file

Use/update the volume number in file.


-V name, --label=name

Name this volume name.


--wildcards

Use wildcards when excluding files.


--wildcards-match-slash

Wildcards match / when excluding files.


-W, --verify

Check archive for corruption after creation.


-z, --gzip, --gunzip, --ungzip

Compress files with gzip before archiving them, or uncompress them with gunzip before extracting them.


-Z, --compress, --uncompress

Compress files with the old compress command before archiving them, or uncompress them with uncompress before extracting them.

Examples

Create an archive of /bin and /usr/bin (c), show the command working (v), and write on the tape in /dev/rmt/0 :

     tar -cvf /dev/rmt/0 /bin /usr/bin

List the archive's contents in a format like ls -l:

     tar -tvf /dev/rmt/0

Extract the /bin directory:

     tar -xvf /dev/rmt/0 /bin

Create an archive of the current directory, and store it in a file /tmp/backup.tar on the system. (Backing up a directory into a file in that directory almost never works.)

     tar -cvf /tmp/backup.tar .

Similar, but compress the archive file:

     tar -cvf - . | gzip > /tmp/backup.tar.gz

(The - tells tar to store the directory on standard output, which is then redirected through the pipe.)

Do the same, but using GNU tar:

     tar -cvzf /tmp/backup.tar.gz .

Copy a directory tree from one location to another:

     # cd olddir; tar -cf - . | (cd newdir; tar -xvpf -)

tcsh

     tcsh [options] [file [arguments]]

An extended version of the C shell, a command interpreter into which all other commands are entered. For more information, see Chapter 5.

tee

     tee [options] [files]

Duplicate the standard input ; send one copy to standard output and another copy to files.

Options


-a, --append

Append output to files.


-i, --ignore-interrupts

Ignore all interrupts.

Examples

Display a who listing on the screen and store it in two files:

     who | tee userlist ttylist

Display misspelled words and add them to existing typos :

     spell ch02 | tee -a typos

telnet

     telnet [options] [host [port]]

Communicate with another host using the Telnet protocol. host may be either a name or a numeric Internet address (dot format). telnet has a command mode (indicated by the telnet> prompt) and an input mode (usually a login session on the host system). If no host is given, telnet defaults to command mode. You can also enter command mode from input mode by typing the escape character ^]. In command mode, type ? or help to list the available commands.

In days of yore, telnet used a direct, clear, unencrypted data stream for all information, including login names and passwords. Doing so today is terribly insecure, and you should not use telnet if you cannot use the encryption facility. (See ssh for an alternative.) Nevertheless, telnet remains useful for network debugging; for example, connecting directly to SMTP, POP3, or IMAP servers for testing.


Common Options


-8

Use an eight-bit data path. This negotiates the BINARY option for input and output.


-a

Attempt an automatic login. This is the default on Mac OS X.


-c

Don't read $HOME/.telnetrc at startup.


-d

Set the debug option to TRue.


-e c

Use c as the escape character. The default is ^]. A null value disables the escape character mechanism.


-E

Don't have an escape character.


-f

If using Kerberos, forward the local credentials to the remote system.


-F

Like -f, but includes credentials that were already forwarded to the local system too.


-k realm

For Kerberos, obtain a ticket for the remote host from the realm realm, instead of the remote host's default realm.


-K

Do not allow automatic login to the remote system.


-l user

Use the ENVIRON option to pass the value of the USER environment variable.


-L

Use an eight-bit data path on output. This negotiates the BINARY option only for output.


-n file

Record trace information in file.


-r

Provide an rlogin-style interface, in which the escape character is ~ and is only recognized after a carriage return. The regular telnet escape character must still be used before a telnet command. "~. ENTER" and "~ ^Z" terminates or stops a session, respectively.


-x

Enable encryption if possible. This is the default on Mac OS X.


-X atype

Disable authentication type atype.

Solaris Host Specification


[[! ]@ host1[@ host2 ...]] desthost

Uses loose source routing to desthost, sending the connection through host1, host2, .... With a leading !, uses strict source routing. IPv6 connections may use only loose source routing.

GNU/Linux Options


-7

Strip the eighth bit on input and output.


-b hostalias

Use bind(2) to bind the local socket to an aliased address or the address of an interface other than the one that would be chosen by connect(2).

Mac OS X Options


-4

Use IPv4.


-6

Use IPv6.


-N

Do not do IP address to name lookup if the remote host is provided as an IP address.


-s source_address

Set the source IP address of the connection to source_address. Both IP addresses and hostnames may be used.


-S tosval

Set the IP type-of-service option to tosval, which may be numeric, or a symbolic name from /etc/iptos, if that file exists.


-u

Use a Unix Domain socket, i.e., one accessed as a file pathname.


-y

Do not encrypt the data stream.

test

     test expression             or     [ expression ]

Evaluate an expression and, if its value is true, return a zero exit status ; otherwise, return a nonzero exit status. In shell scripts, you can use the alternate form [ expression ]. The brackets are typed literally and must be separated from expression. Generally, this command is used with conditional constructs in shell programs. See Chapter 4 for more information on test.

time

     time [option] command [arguments]

Execute a command with optional arguments and print the total elapsed time, execution time, process execution time, and system time of the process (all in seconds). Times are printed on standard error. time is a built-in command in all of the Bash, Korn, and C shells. This entry describes the external command that lives in the filesystem.

Common Option


-p, --portability

Print the real, user, and system times with a single space separating the title and the value, instead of a tab. (Mac OS X uses a tab.)

GNU/Linux Options


-a, --append

Used with -o to append the output to file instead of overwriting it.


-f format, --format=format

Specify the output format. Overrides any format specified in the TIME environment variable.


-o file, --output=file

Send the output from time to the specified file instead of to standard error. If file exists, it is overwritten.


-v, --verbose

Give verbose output, providing all available information.


-V, --version

Print version information and exit.

Mac OS X Option


-l

Print the contents of the process's struct rusage structure. See getrusage(2).

touch

     touch [options] [date] files

For one or more files, update the access time and modification timestamp to the current time and date, or update to the optional date. date is a date and time in the format mmddhhmm [yy ]. touch creates the files if they don't exist. touch is useful in forcing other commands to handle files a certain way; e.g., the operation of make, and sometimes find, relies on a file's access and modification times.

Common Options


-a, --time=access, --time=atime, --time=use

Update only the access time.


-c, --no-create

Do not create nonexistent files.


-m, --time=modify, --time=mtime

Update only the modification time.


-r file, --reference=file

Use the access and/or modification times of file instead of the current time.


-t time

Use the time as it is provided by time, which has the form [[cc ]yy ]mmddhhmm [.ss ].

GNU/Linux Options


-d time, --date=time

Change the time value to the specified time instead of the current time. time can use several formats and may contain month names, time zones, a.m. and p.m. strings, etc.


-f

Accepted but ignored.

Mac OS X Option


-f

Force; attempt to update the times, even if the file permissions do not allow it.

tr

     tr [options] [string1 [string2]]

Copy standard input to standard output, performing substitution of characters from string1 to string2 or deletion of characters in string1. Some older System V systems require that string1 and string2 be enclosed in square brackets. (This is true of Solaris's /usr/bin/tr, for example.) Most other versions do not have this requirement. POSIX-compliant versions do not have this requirement either.

Common Options


-c, --complement

Complement characters in string1 with characters in the current character set. The complement is the set of all characters not in string1. This option works in terms of byte values.


-d, --delete

Delete characters in string1 from output.


-s, --squeeze-repeats

Squeeze out repeated output characters in string2.

Solaris and Mac OS X Option


-C

Like -c, but work in terms of characters, which may be multibyte values, depending upon the local character set.

GNU/Linux Option


-t, --truncate-set1

Truncate string1 to the length of string2 before processing the input.

Mac OS X Option


-u

Force output to be unbuffered.

Examples

Change uppercase to lowercase in a file:

     tr  'A-Z'   'a-z'  < file      Modern systems, traditional BSD     tr '[A-Z]' '[a-z]' < file      Old System V systems

Modern systems allow the use of character classes:

     tr '[:upper:]' '[:lower:]' < file

Turn spaces into newlines (ASCII code 012):

     tr ' ' '\012' < file

Strip blank lines from file and save in new.file (or use \011 to change successive tabs into one tab):

     tr -s "" "\012" < file > new.file

Delete colons from file; save result in new.file :

     tr -d : < file > new.file

Make long search path more readable:

     echo $PATH | tr ':' '\n'

troff

     troff [options] [files]

Document formatter for laser printer or typesetter. See Chapter 18.

true

     true

A do-nothing command that returns a successful (zero) exit status. Normally used in Bourne shell scripts. See also true.

true is built into most modern shells.

tset

     tset [options] [type]

Set terminal modes. Without arguments, the terminal is reinitialized according to the TERM environment variable. tset is typically used in startup scripts (.profile or .login). type is the terminal type; if preceded by a ?, tset prompts the user to enter a different type, if needed. Press the ENTER key to use the default value, type. On Solaris, this command is found is /usr/ucb. See also reset.

Common Options


-

Print terminal name on standard output; useful for passing this value to TERM.


-e c

Set erase character to c; default is ^H (backspace).


-i c

Set interrupt character to c (default is ^C).


-I

Do not output terminal initialization setting.


-k c

Set line-kill character to c (default is ^U).


-m[ port[ baudrate]: type]

Declare terminal specifications. port is the port type (usually dialup or plugboard). tty is the terminal type; it can be preceded by ? as above. baudrate checks the port speed and can be preceded by any of these characters:

>

Port must be greater than baudrate.

<

Port must be less than baudrate.

@

Port must transmit at baudrate.

!

Negate a subsequent >, <, or @ character.

?

Prompt for the terminal type. With no response, use the given type.



-Q

Do not print "Erase set to" and "Kill set to" messages.


-r

Report the terminal type.


-s

Return the values of TERM assignments to shell environment. This is a commonly done via eval 'tset -s' (in the C shell, you would surround this with the commands set noglob and unset noglob).

Solaris Option


-n

Initialize "new" tty driver modes. Useless because of redundancy with the default stty settings that incorporate the functionality of the BSD "new" tty driver.

GNU/Linux and Mac OS X Options


-q

Print the terminal type on standard output but do not initialize the terminal.


-V

Print the version of ncurses used for this program and exit.

Examples

Set TERM to wy50:

     eval 'tset -s wy50'

Prompt user for terminal type (default is vt100):

     eval 'tset -Qs -m '?vt100''

Similar to above, but the baudrate must exceed 1200:

     eval 'tset -Qs -m '>1200:?xterm''

Set terminal via modem. If not on a dial-in line, the ?$TERM causes tset to prompt with the value of $TERM as the default terminal type:

     eval 'tset -s -m dialup:'?vt100' "?$TERM"'

tty

     tty [options]

Print the device name of your terminal. This is useful for shell scripts and often for commands that need device information.

Common Option


-s, --quiet, --silent

Return only the codes: 0 (a terminal), 1 (not a terminal), 2 (invalid options used).

Solaris Option


-l

Print the synchronous line number, if on an active synchronous line.

type

     type program ...

Print a description of program, i.e., whether it is a shell built-in, a function, or an external command. type is built into the Bash and Korn shells. See Chapter 4 and also see which.

Example

Describe cd and ls:

     $ type cd ls          From Bash     cd is a shell builtin     ls is hashed (/bin/ls)

umask

     umask [value]

Print the current value of the file creation mode mask , or set it to value, a three-digit octal code specifying the read-write-execute permissions to be turned off when new files are created. Normally used in .login or .profile. umask is a built-in command in the Bash, Korn, and C shells (see Chapters 4 and 5).

umask number

File permission

Directory permission

0

rw-

rwx

1

rw-

rw-

2

r--

r-x

3

r--

r--

4

-w-

-wx

5

-w-

-w-

6

---

--x

7

---

---


Examples

Turn off write permission for others:

     umask 002                Produces file permission -rw-rw-r--

Turn off all permissions for group and others:

     umask 077                Produces file permission -rw-------

Note that you can omit leading zeroes.

uname

     uname [options]

Print the current Unix system name.

Common Options


-a, --all

Report the information supplied by all the other options.


-m, --machine

The hardware name.


-n, --nodename

The node name.


-p, --processor

The host's processor type.


-r, --kernel-release

The operating system release.


-s, --kernel-name

The system name. This is the default action when no options are provided.


-v, --kernel-version

The operating system version.

Solaris and GNU/Linux Option


-i, --hardware-platform

The hardware platform name. (For example on Solaris, SUNW,Ultra-4; compare to sparc from -p.)

Solaris Options


-S name

Change the nodename to name. Privileged users only.


-X

Print expanded information as expected by SCO Unix systems.

GNU/Linux Option


-o, --operating-system

Print the operating system name.

umount

     umount [options] [arguments]

Unmount a filesystem. This command is very system-specific. See the umount entries in the sections for each operating system.

unexpand

     unexpand [options] [files]

Convert spaces back into an appropriate number of tab characters. unexpand reads the named files, or standard input if no files are provided. See also expand.

Common Options


-a, --all

Replace spaces with tabs everywhere possible, not just leading spaces and tabs.


-t tablist, --tabs=tablist

Interpret tabs according to tablist, a space- or comma-separated list of numbers in ascending order that describes the "tabstops" for the input data.

GNU/Linux Option


--first-only

Convert only leading whitespace into tabs. Overrides -a.

uniq

     uniq [options] [file1 [file2]]

Remove duplicate adjacent lines from sorted file1, sending one copy of each line to file2 (or to standard output). Often used as a filter. Specify only one of -c, -d, or -u. See also comm and sort.

Common Options


-c, --count

Print each line once, counting instances of each.


-d, --repeated

Print duplicate lines once, but no unique lines.


-f n, --skip-fields=n

Ignore first n fields of a line. Fields are separated by spaces or by tabs.


-s n, --skip-chars=n

Ignore first n characters of a field.


-u, --unique

Print only unique lines (no copy of duplicate entries is kept).


-n

Like -f. This original, pre-POSIX syntax is deprecated; use -f instead.


+n

Like -s. This original, pre-POSIX syntax is deprecated; use -s instead.

GNU/Linux Options


-D, --all-repeated[= method]

Print all duplicate lines. -D takes no delimiter method. The delimiter method method describes how uniq should delimit groups of repeated lines in the output. It takes one of the values none (default), prepend (output a newline before each group), or separate (output a newline after each group).


-i, --ignore-case

Ignore case differences when checking for duplicates.


-w n, --check-chars=n

Compare only first n characters per line (beginning after skipped fields and characters).

Examples

Send one copy of each line from list to output file list.new (list must be sorted):

     uniq list list.new

Show which names appear more than once:

     sort names | uniq -d

Show which lines appear exactly three times:

     sort names | uniq -c | awk '$1 =  = 3'

units

     units     units [options] [from-unit to-unit]

Interactively supply a formula to convert a number from one unit to another. Use EOF to exit. Known units are maintained in a system table, and the GNU/Linux and Mac OS X versions let you supply your own units file. They also allow you to supply units on the command line, so that the program can be used in a batch fashion.

GNU/Linux and Mac OS X Common Options


-f file, --file=file

Read units from file.


-q, --quiet, --silent

Do not prompt, and do not display statistics.

GNU/Linux Options


-c, --check

Verify that all units reduce to primitive units.


--check-verbose

Like -c, but list the units as they're checked, for finding infinite loops.


-e, --exponential

Use exponential format output.


-h, --help

Print a command-line summary and exit.


-o format, --output-format=format

Use printf(3)-style format format for formatting values. format should be appropriate for a floating-point value.


-s, --strict

Do not do the reciprocal unit conversion.


-v, --verbose

Be more verbose.


-V, --version

Print version information and exit.

Mac OS X Option


-v

Print the version number.

unix2dos

     unix2dos [options] unixfile dosfile

Solaris and GNU/Linux only. Convert files using the ISO standard characters to their DOS counterparts. If unixfile and dosfile are the same, the file is overwritten after the conversion is done. See also dos2unix.

For the GNU/Linux version, the options are the same as for dos2unix; see the dos2unix entry for the list.

Solaris Options


-ascii

Add extra carriage returns for use under DOS.


-iso

Same as the default action.


-437

Use the US code page.


-7

Convert 8-bit Solaris characters to 7-bit DOS characters.


-850

Use the multilingual code page.


-860

Use the Portugese code page.


-863

Use the French Canadian code page.


-865

Use the Danish code page.

unzip

     unzip [options[modifiers]] zipfile ... [extraction options]     unzip -Z [zipinfo options] zipfile ...

unzip prints information about or extracts files from ZIP format archives. The zipfile is a ZIP archive whose filename ends in .zip. The .zip can be omitted from the command line; unzip supplies it. zipfile may also be a shell-style wildcard pattern (which should be quoted); all matching files in the ZIP archive will be acted upon. The behavior of options is affected by the various modifiers.

In the second form, the options are taken to be zipinfo options, and unzip performs like that command. See zipinfo for more information.

Options may also be included in the UNZIP environment variable, to set a default behavior. Options on the command line can override settings in $UNZIP by preceding them with an extra minus.

When extracting files, if a file exists already, unzip prompts for an action. You may to choose to overwrite or skip the existing file, overwrite or skip all files, or rename the current file.

Notes

  • unzip and its companion program zip are part of the InfoZIP project. InfoZIP is an open collaborative compressed archive format, and implementations exist for Unix, Amiga, Atari, VMS and OpenVMS, MS-DOS, Macintosh, Minix, OS/2, Windows NT, and many others. It is the only similar format you can expect to port to all of these systems without difficulty. The web home page is http://www.info-zip.org/.

  • Unlike most Unix tar implementations, zip removes leading slashes when it creates a ZIP archive, so there is never any problem unbundling it at another site.

  • The Java Archive format (.jar) is based on ZIP; zip and unzip can process .jar files with no trouble.

  • The jar tool may be easier to use for working with .zip files, especially since its options are similar to those of tar.

The following lists intentionally omit obsolete options and those that are specific to non-Unix platforms.

Extraction Options


-d dir

Extract files in dir instead of in the current directory. This option need not appear at the end of the command line.


-x files

Exclude. Do not extract archive members that match files.

Options


-A

Print help for the shared library programming interface (API).


-c

Print files to standard output (the CRT). Similar to -p, but a header line is printed for each file, it allows -a, and automatically does ASCII to EBCDIC conversion. Not in the unzip usage message.


-f

Freshen existing files. Only files in the archive that are newer than existing disk files are extracted. unzip queries before overwriting, unless -o is used.


-l

List archived files, in short format (name, full size, modification time, and totals).


-p

Extract files to standard output (for piping). Only the file data is printed. No conversions are done.


-q[q]

Be quiet; suppress most of the informative messages provided during processing. Use -qq to suppress all messages.


-t

Test the archived files. Each file is extracted in memory, and the extracted file's CRC is compared to the stored CRC.


-T

Set the timestamp on the archive itself to be that of the newest file in the archive.


-u

Same as -f, but also extract any files that don't exist on disk yet.


-v

Be verbose or print diagnostic information. -v is both an option and a modifier, depending upon the other options. By itself, it prints the unzip ftp site information, information about how it was compiled, and what environment variable settings are in effect. With a zipfile, it adds compression information to that provided by -l.


-X

Restore the owner and group (UID and GID) recorded in the archive. The default is to use the UID and GID of the extracting user.


-z

Only print the archive comment.


-Z

Run as zipinfo. Remaining options are zipinfo options. See zipinfo for more information.

Modifiers


-:

Allow writing of files outside the directory in which extraction is taking place, via ../ in pathname components. Older versions of unzip allowed this by default; current versions disallow it for safety. This option reenables the original behavior. GNU/Linux and Mac OS X only.


-a[a]

Convert text files. Normally, files are extracted as binary files. This option causes text files to be converted to the native format (e.g., adding or removing CR characters in front of LF characters). EBCDIC-to-ASCII conversion is also done as needed. Use -aa to force all files to be extracted as text.


-b

Treat all files as binary.


-B

Save a backup copy of each overwritten file in file~. Only available if compiled with UNIXBACKUP defined.


-C

Ignore case when matching filenames. Useful on non-Unix systems where filesystems are not case-sensitive.


-j

"Junk" paths. Extract all files in the current extraction directory, instead of reproducing the directory tree structure stored in the archive.


-L

Convert filenames to lowercase from archives created on uppercase-only systems. By default, filenames are extracted exactly as stored in the archive.


-M

Pipe output through the internal pager, which is similar to more. Press the ENTER key or spacebar at the --More-- prompt to see the next screenful.


-n

Never overwrite existing files. If a file already exists, don't extract it, just continue on without prompting. Normally, unzip prompts for an action.


-o

Overwrite existing files without prompting. Often used together with -f. Use with care.

Examples

List the contents of a ZIP archive:

     unzip -lv whizprog.zip

Extract C source files in the main directory, but not in subdirectories:

     unzip whizprog.zip '*.[ch]' -x '*/*'

uptime

     uptime

Print the current time, amount of time the system has been up, number of users logged in, and the system-load averages. This output is also produced by the first line of the w command. GNU/Linux accepts -V to print the program's version information.

users

     users [file]

Display the currently logged-in users as a space-separated list. Information is read from a system file such as /var/adm/utmp, although the location may vary from system to system. On Solaris, this program is in /usr/ucb.

uudecode

     uudecode [options] [file]

Read a uuencoded file and re-create the original file with the same mode and name.

Common Option


-o file

Write output to file instead of to the filename recorded in the input. On GNU/Linux, use -o /dev/stdout to use uudecode in a pipeline.

Solaris and Mac OS X Option


-p

Write the decoded file to standard output, making it possible to use uudecode in a pipeline.

Mac OS X Options


-c

Continue; attempt to decode more than one output file from the same input.


-i

Do not overwrite files.


-s

Do not strip the final pathname to just the basename. Normally, uudecode removes leading directory components from the output filename for security.

vi

     vi [options] [files]

A screen-oriented text editor based on ex. See Chapter 9 for more information on vi and ex.

view

     view [options] [files]

Same as vi -R. See Chapter 9.

vim

     vim [options] [files ...]

An enhanced version of the vi screen editor. Both vi and vim are covered in Chapter 9.

vimdiff

     vimdiff [options] file1 file2 [file3]     gvimdiff [options] file1 file2 [file3]

Edit two or three files with vim, highlighting the differences. If invoked as gvimdiff, the GUI is used instead. This sets the diff, wrap, and scrollbind options. It also sets foldmethod=diff and foldcolumn=2, which puts ranges of lines that aren't changed into a fold and makes folds easy to spot.

By default, the screen is split vertically, as if with -O. Use -o to get a horizontal split.

For more information about vim, see Chapter 9.

w

     w [options] [user]

Print summaries of system usage, currently logged-in users, and what they are doing. w is essentially a combination of uptime, who, and ps -a. Display output for one user by specifying user.

Common Option


-h

Suppress headings and uptime information.

Solaris and GNU/Linux Option


-s

Display in short format.

Solaris Options


-l

Display in long format (the default).


-u

Print just the heading line. Equivalent to uptime.


-w

Same as -l.

GNU/Linux Options


-f

Toggle printing the from (remote hostname) field.


-u

Ignore the username while figuring out the current process and CPU times.


-V

Display version information.

Mac OS X Options


-d

Dump the entire process list per controlling tty, not just the top level process.


-i

Sort the output by idle time.


-M corefile

Use corefile for the name list of the running system instead of /dev/kmem.


-n

Don't resolve network addresses to turn them back into hostnames.


-N system_image

Use system_image for the name list instead of /mach.

wait

     wait [n]

Wait for all background processes to complete and report their termination status. Used in shell scripts. If n is specified, wait only for the process with process ID n. wait is a built-in command in the Bash, Korn, and C shells. See Chapters 4 and 5 for more information.

wc

     wc [options] [files]

Word count. Print a character, word, and line count for files. If multiple files, print totals as well. If no files are given, read standard input. See other examples under ls and sort.

Common Options


-c, --bytes

Print byte count only.


-l, --lines

Print line count only.


-m, --chars

Print character count only. This will be different than -c in a multibyte character environment.


-w, --words

Print word count only.

Solaris Option


-C

Same as -m.

GNU/Linux Option


-L, --max-line-length

Print length of longest line.

Examples

Count the number of users logged in:

     who | wc -l

Count the words in three essay files:

     wc -w essay.[123]

Count lines in file named by $file (don't display filename):

     wc -l < $file

whatis

     whatis commands

Look up one or more commands in the online manpages, and display a brief description. Same as man -f. The MANPATH environment variable can affect the results obtained with this command. See also apropos.

which

     which [options] [commands]

List which files are executed if the named commands are run as a command. which reads the user's .cshrc file (using the source built-in command), checking aliases and searching the path variable. Users of the Bourne or Korn shells can use the built-in type command as an alternative. (See type, Chapters 4 and 5.)

GNU/Linux Options


-a, --all

Print all matches, not just the first.


-i, --read-alias

Read aliases from standard input and write matches to standard output. Useful for using an alias for which.


--read-functions

Read shell functions from standard input and report matches to standard output. Useful for also using a shell function for which itself.


--show-dot

If a matching command is found in a directory that starts with a dot, print ./cmdname instead of the full pathname.


--show-tilde

Print a tilde (~) to indicate the user's home directory. Ignored if the user is root.


--skip-alias

Ignore --read-alias if present. Useful for finding normal binaries while using --read-alias in an alias for which.


--skip-dot

Skip directories that start with a dot.


--skip-functions

Ignore --read-functions if present. Useful when searching for normal binaries while using --read-functions in an alias or function for which.


--skip-tilde

Skip directories that start with a tilde (~) and executables in $HOME.


--tty-only

Stop processing options on the right if not on a terminal.


-v, -V, --version

Print version information and then exit.

Example

$ which file ls     /usr/bin/file     ls:      aliased to ls -sFC

who

     who [options] [file]

Display information about the current status of the system. With no options, list the names of users currently logged in to the system. An optional system file (the default varies per system) can be supplied to give additional information. who is usually invoked without options, but useful options include am i and -u. For more examples, see cut, line, paste, tee, and wc.

Common Options


-H, --heading

Print headings.


-m

Report only about the current terminal.


-q, --count

"Quick." Display only the usernames.


-s, --short

List the name, line, and time fields (the default behavior).


-T, --mesg, --message, --writable

Report whether terminals are writable (+), not writable (-), or unknown (?).


-u, --users

Report terminal usage (idle time). A dot (.) means less than one minute idle; old means more than 24 hours idle.


am i

Print the username of the invoking user. (Similar to results from id.)

Solaris and GNU/Linux Options


-a, --all

Use the -b, -d, -l, -p, -r, -t, -T, and -u options.


-b, --boot

Report information about the last reboot.


-d, --dead

Report expired processes.


-l, --login

Report inactive terminal lines.


-p, --process

Report previously spawned processes.


-r, --runlevel

Report the run level.


-t, --time

Report the last change of the system clock (via date).

Solaris Option


-n x

Display x users per line (works only with -q).

GNU/Linux Options


-i, --idle

Present idle time as HOURS:MINUTES, . (dot), or old. (Deprecated; use -u.)


--lookup

Use DNS to canonicalize hostnames for people logged in remotely.


-w

Same as -T.

Example

This sample output was produced at 8 a.m. on April 17:

     $ who -uH     NAME    LINE   TIME         IDLE   PID  COMMENTS     martha  ttyp3  Apr 16 08:14 16:25  2240     george  ttyp0  Apr 17 07:33   .  15182

Since martha has been idle since yesterday afternoon (16 hours), it appears that Martha isn't at work yet. She simply left herself logged in. George's terminal is currently in use. (He likes to beat the traffic.)

whoami

     whoami

Print the username based on effective user ID. On Solaris, this command is in /usr/ucb. On GNU/Linux and Mac OS X, it's equivalent to id -un.

xargs

     xargs [options] [command]

Execute command (with any initial arguments), but read remaining arguments from standard input instead of specifying them directly. xargs passes these arguments in several bundles to command, allowing command to process more arguments than it could normally handle at once. The arguments are typically a long list of filenames (generated by ls or find, for example) that get passed to xargs via a pipe.

Without a command, xargs behaves similarly to echo, simply bundling the input lines into output lines and printing them to standard output.

Common Options


-E string

Stop passing arguments when argument string is encountered.


-I string

Pass arguments to command, replacing instances of string on the command line with the current line of input.


-L n

Execute command for n lines of arguments.


-n count, --max-args=count

Execute command with up to count arguments.


-p, --interactive

Prompt for a y to confirm each execution of command. Implies -t.


-s max, --max-chars=max

Each argument list can contain up to max characters. (Older systems limited n to 470. The default is system-dependent.)


-t, --verbose

Echo each command before executing.


-x, --exit

Exit if argument list exceeds n characters (from -s); -x takes effect automatically with -i and -l.

Solaris and GNU/Linux Options


-e[ string], --eof[= string]

Use string as the default logical EOF string (default is underscore). An omitted string disables the logical EOF capability.


-i[ string], --replace[= string]

Like -I but default string is { }.


-l[ n], --max-lines[= n]

Same as -L, but default n is 1.

GNU/Linux and Mac OS X Option


-0, --null

Filenames are separated with zero bytes (ASCII NUL) instead of spaces and newlines. For use with find -print0.

GNU/Linux Options


-P max, --max-procs=max

Allow no more than max processes to run at once. The default is 1. A maximum of 0 allows as many as possible to run at once.


-r, --no-run-if-empty

Do not run command if standard input contains only blanks.

Mac OS X Options


-J string

When string is found among the arguments on the command line, replace its first occurrence with the current input list. This happens instead of appending the list to the given arguments.


-R count

Use count as the maximum number of arguments in which -I will do replacements.

Examples

grep for pattern in all files on the system:

     find / -print | xargs grep pattern > out &

Run diff on file pairs (e.g., f1.a and f1.b, f2.a and f2.b ...):

     echo "$@" | xargs -n2 diff

The previous line could be invoked as a shell script, specifying filenames as arguments.

Display file, one word per line:

     cat file | xargs -n1

Move files in olddir to newdir, showing each command:

     ls olddir | xargs -i -t mv olddir/{  } newdir/{  }

xgettext

     xgettext [options] files     xgettext -h

Solaris and GNU/Linux only. Extract messages (specially marked strings) from C and C++ source files. Place them in a "portable object" file (.po) for translation and compilation by msgfmt. By default, xgettext extracts strings only inside calls to the gettext (3C) and dgettext (3C) functions. Source files are named on the command line. A filename of - indicates the standard input. See also gettext and msgfmt.

GNU gettext extends the original Solaris gettext design and is able to extract strings from source files for a large number of languages. The URL for it is http://www.gnu.org/software/gettext.

Common Options


-a, --extract-all

Extract all strings, not just those in calls to gettext or dgettext. (GNU/Linux: applies to languages C, C++, ObjectiveC, Shell, Python, Lisp, EmacsLisp, librep, Scheme, Java, C#, awk, Tcl, Perl, PHP, GCC-source, and Glade.)


-c tag, --add-comments[= tag]

Copy source file comments marked with tag into the .po file as #-delimited comments.


-d domain, --default-domain=domain

Use domain.po as the output file instead of messages.po.


-h, --help

Print a help message on the standard output.


-j, --join-existing

Join (merge) extracted messages with those in the current .po file. Domain directives in the existing .po file are ignored.


-m prefix, --msgstrr-prefix=prefix

Fill in each msgstr with prefix. Intended for debugging. The GNU version allows prefix to be optional.


-M suffix, --msgstr-suffix=suffix

Fill in each msgstr with suffix. Intended for debugging. The GNU version allows suffix to be optional.


-n, --add-location

Add comments to the .po file indicating the source filename and line number where each string is used.


-p path, --output-dir=path

Place output files in the directory path.


-s, --sort-output

Sort the output by msgid (original string), with all duplicates removed.


-x exfile, --exclude-file=exfile

exfile is a .po file with msgids that are not to be extracted (i.e., to be excluded).

GNU/Linux Options


--copyright-holder=string

Set the copyright holder in the output file.


-C, --c++

Short for --language=C++.


--debug

Produce more detailed output, intended for debugging xgettext.


-D dir, --directory=dir

Add dir to the list of directories searched for input.


-e, --no-escape

Do not use C escapes in the output (the default).


-E, --escape

Do use C escapes in the output.


-f file, --files-from=exfile

Read list of input files from file.


--force-po

Write the .po file even if it will be empty.


--foreign-user

Do not place the FSF copyright information into the file.


--flag=funcname: argnum: flag

Apply flag to the argnum th argument to function funcname. This is a specialized option, see the online Info manual for details. For languages: C, C++, ObjectiveC, Shell, Python, Lisp, EmacsLisp, librep, Scheme, Smalltalk, Java, C#, awk, YCP, Tcl, Perl, PHP, and GCC-source.


--from-code=encoding

Input files use encoding. Not valid for languages Python, Tcl, or Glade.


-F, --sort-by-file

Sort the output by input file location.


-i, --indent

Use an indented style when writing the .po file.


-k [ word], --keyword[= word]

Additional keyword to search for. Without word, do not recognize the default keywords. Valid for languages C, C++, ObjectiveC, Shell, Python, Lisp, EmacsLisp, librep, Scheme, Java, C#, awk, Tcl, Perl, PHP, GCC-source, and Glade.


-L lang, --language=name

Source files are in language lang. Known languages are C, C++, ObjectiveC, PO, Shell, Python, Lisp, EmacsLisp, librep, Scheme, Smalltalk, Java, JavaProperties, C#, awk, YCP, Tcl, Perl, PHP, GCC-source, NXStringTable, RST, and Glade.


--msgid-bugs-address=user@ domain

Supply the bug-reporting address for problems with the original msgid strings.


--no-location

Do not write #: filename:line lines.


--no-wrap

Do not break long lines.


-o file, --output=exfile

Write the output to file. Use - for standard output.


--omit-header

Do not write a header with a msgid "" entry.


--properties-input

Create a .properties file.


--qt

Extract Qt format strings. Valid only for C++.


--strict

Use the Uniforum format for the .po file. Avoid this if possible, it doesn't allow for GNU extensions.


--stringtable-input

Create a NeXTstep/GNUstep .strings file.


-T, --trigraphs

Interpret ANSI C trigraphs. Only for C, C++, and ObjectiveC.


-v, --version

Print version information and exit.


-w count, --width=count

Set the output line width to count.

yacc

     yacc [options] file     byacc [options] filename

Given a file containing a context-free LALR(1) grammar, convert it to tables for subsequent parsing and send output to y.tab.c. This command name stands for yet another compiler-compiler. On Solaris yacc is found in /usr/ccs/bin. See also lex, flex, and bison, and lex & yacc, which is listed in the Bibliography.

Mac OS X uses Berkeley Yacc for yacc, which accepts the traditional options as well as -o. GNU/Linux provides Berkeley Yacc under the name byacc.

Common Options


-d

Generate y.tab.h, producing #define statements that relate yacc's token codes to the token names declared by the user.


-l

Exclude #line constructs from code produced in y.tab.c. (Use after debugging is complete.)


-t

Compile runtime debugging code by default.


-v

Generate y.output, a file containing diagnostics and notes about the parsing tables.


-V

Print the version of yacc on standard error. (May not be in all versions.)

GNU/Linux and Mac OS X Option


-r

Produce separate files for code and tables named y.code.c and y.tab.c, respectively.

Solaris Options


-b prefix

Use prefix instead of y for the generated filenames.


-p prefix

Use prefix instead of yy for all external names in the generated parser.


-P parser

Use parser instead of /usr/ccs/bin/yaccpar.


-Qc

Place version information about yacc in y.tab.c (if c = y) or suppress information (if c = n, the default).

Berkeley Yacc Option


-o filename

Write the generated parser to filename instead of to y.tab.c.

zcat

     zcat [files]

Uncompress one or more compressed files to the standard output, leaving files unchanged. See bzip2 and gzip.

On Solaris, zcat is the original version related to compress. GNU/Linux and Mac OS X use the version related to gzip, which can decompress .Z and .gz files.

zip

     zip [options] zipfile [files]

Archive files in InfoZIP format . These files can be retrieved using unzip. The files are compressed as they are added to the archive. Compression ratios of 2:1 to 3:1 are common for text files. zip may also replace files in an existing archive. With no arguments, display the help information. See also zipinfo and unzip.

Default options may be placed in the ZIPOPT environment variable, with the exceptions of -i and -x. Multiple options may be included in ZIPOPT.

The zip source code is readily available from http://www.info-zip.org/. There are a number of important notes in the unzip entry. Go there for more information.

The following list intentionally omits obsolete options and those that are specific to non-Unix platforms.

Options


-b path

Use path as the location to store the temporary ZIP archive while updating an existing one. When done, copy the temporary archive over the new one. Useful primarily when there's not enough disk space on the filesystem containing the original archive.


-c

Add one-line comments for each file. zip first performs any file operations and then prompts you for a comment describing each file.


-d

Delete entries from a ZIP archive. Filenames to be deleted must be entered in uppercase if the archive was created by PKZIP on an MS-DOS system.


-D

Don't create entries in the archive for directories. Usually entries are created, so that attributes for directories may be restored upon extraction.


-e

Encrypt the archive. zip prompts on the terminal for a password and prompts twice, to avoid typing errors. If standard error is not a terminal, zip exits with an error.


-f

Freshen (replace) an existing entry in the ZIP archive if the file has a more recent modification time than the one in the archive. This doesn't add files that are not already in the archive: use -u for that. Run this command from the same directory where the ZIP archive was created, since the archive stores relative pathnames.


-F, -FF

Fix the ZIP archive. This option should be used with care; make a backup copy of the archive first. The -FF version does not trust the compressed sizes in the archive, and instead scans it for special "signatures" that identify the boundaries of different archive members. See the manpage for more information.


-g

Grow the archive (append files to it).


-h

Display the zip help information.


-i files

Include only the specified files, typically specified as a quoted shell wildcard-style pattern.


-j

"Junk" the path; i.e., store just the name of the saved file, not any directory names. The default is to store complete paths, although paths are always relative.


-J

Strip any prepended data (e.g., an SFX stub, for self-extracting executables) from the archive.


-k

Create an archive that (attempts to) conform to the conventions used under MS-DOS. This makes it easier for PKUNZIP to extract the archive.


-l

For text files only, translate the Unix newline into a CR-LF pair. Primarily for archives extracted under MS-DOS.


-ll

For text files only, translate CR-LF into a Unix newline.


-L

Display the zip license.


-m

"Move" the files into the ZIP archive. This actually deletes the original files and/or directories after the archive has been created successfully. This is somewhat dangerous; use -T in conjunction with this option.


-n suffixlist

Do not compress files with suffixes in colon-separated suffixlist. Useful for sound or image files that often have their own, specialized compression method.


-o

Set the modified time of the ZIP archive to be that of the youngest file (most recently modified) in the archive.


-q

Quiet mode. Don't print informational messages and comment prompts. Most useful in shell scripts.


-r

Recursively archive all files and subdirectories of the named files. The -i option is also useful in combination with this one.


-t mmddyy

Ignore files modified prior to the date given by mmddyy.


-T

Test the new ZIP archive's integrity. If the test fails, an existing ZIP archive is not changed, and with -m, no files are removed.


-u

Update existing entries in the ZIP archive if the named files have modification dates that are newer than those in the archive. Similar to -f, except that this option adds files to the archive if they aren't already there.


-v

As the only argument, print help and version information, a pointer to the home and distribution Internet sites, and information about how zip was compiled. When used with other options, cause those options to print progress information and provide other diagnostic information.


-x files

Exclude the specified files, typically specified as a quoted shell wildcard-style pattern.


-X

Do not save extra file attributes (extended attributes on OS/2, user ID/group ID, and file times on Unix).


-y

Preserve symbolic links in the ZIP archive, instead of archiving the file the link points to.


-z

Prompt for a (possibly multiline) comment describing the entire ZIP archive. End the comment with a line containing just a period, or EOF.


-n

Specify compression speed: n is a digit between 0 and 9. 0 indicates no compression, 1 indicates fast but minimal compression, 9 indicates slowest but maximal compression. Default is -6.


-@

Read standard input for names of files to be archived. Filenames containing spaces must be quoted using single quotes.

Examples

Archive the current directory into source.zip, including only C source files:

     zip source -i '*.[ch]'

Archive the current directory into source.zip, excluding the object files:

     zip source -x '*.o'

Archive files in the current directory into source.zip, but don't compress .tiff and .snd files:

     zip source -n '.tiff:.snd' *

Recursively archive the entire directory tree into one archive:

     zip -r /tmp/dist.zip .

zipinfo

     zipinfo [options] zipfile ... [exclusion option]

zipinfo prints information about ZIP format archives. The zipfile is a ZIP archive whose filename ends in .zip. The .zip can be omitted from the command line; zipinfo supplies it. zipfile may also be a shell-style wildcard pattern (which should be quoted to protect it from the shell); all matching files in the ZIP archive will be acted upon. See also zip and unzip.

Exclusion Option


-x files

Exclude. Do not extract archive members that match files.

Options


-1

Only list filenames, one per line. Nothing else is printed. For use in shell scripts.


-2

Like -1, but also permit headers, trailers, and ZIP archive comments (-h, -t, -z).


-h

Print a header line with the archive name, size in bytes, and total number of files.


-l

Use "long" format. Like -m, but also print the compressed size in bytes, instead of the compression ratio.


-m

Use "medium" format. Like -s, but also include the compression factor (as a percentage).


-M

Pipe output through the internal pager, which is similar to more. Press the ENTER key or spacebar at the --More-- prompt to see the next screenful.


-s

Use "short" format, similar to ls -l. This is the default.


-t

Print totals for all files (number of files, compressed and uncompressed sizes, overall compression factor).


-T

Print times and dates in a decimal format (yymmdd.hhmmss) that can be sorted.


-v

Use verbose, multipage format.


-z

Print the archive comment.

     < Day Day Up > 


    Unix in a Nutshell
    Unix in a Nutshell, Fourth Edition
    ISBN: 0596100299
    EAN: 2147483647
    Year: 2005
    Pages: 201

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net