touch – change file access and modification times
/usr/ucb/touch [-acfm] file…
touch sets the access and modification times of each file to the current time. file is
created if it does not already exist.
-a Change the access time of file. Do not change the modification time
unless -m is also specified.
-c Do not create file if it does not exist.
-f Attempt to force the touch in spite of read and write permissions on file.
-m Change the modification time of file. Do not change the access time
unless -a is also specified.
See largefile(5) for the description of the behavior of touch when encountering
files greater than or equal to 2 Gbyte ( 2
31
bytes).
The following exit values are returned:
0 touch executed successfully and all requested changes were made.
>0 An error occurred. touch returns the number of files for which the times
could not be successfully modified.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWscpu
touch(1), attributes(5), largefile(5)
touch(1B)
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
USAGE
EXIT STATUS
ATTRIBUTES
SEE ALSO
1558 man pages section 1: User Commands • Last Revised 26 Oct 1995
tplot, t300, t300s, t4014, t450, tek, ver – graphics filters for various plotters
/usr/bin/tplot [-T terminal]
tplot reads plotting instructions from the standard input and produces plotting
instructions suitable for a particular terminal on the standard output.
If no terminal is specified, the environment variable TERM is used. The default terminal
is tek.
Except for ver, the following terminal-types can be used with ‘lpr -g’ (see lpr)to
produce plotted output:
300 DASI 300 or GSI terminal (Diablo® mechanism).
300s | 300S DASI 300s terminal (Diablo mechanism).
450 DASI Hyterm 450 terminal (Diablo mechanism).
4014 | tek Tektronix 4014 and 4015 storage scope with Enhanced Graphics
Module. (Use 4013 for Tektronix 4014 or 4015 without the
Enhanced Graphics Module).
ver Versatec® D1200A printer-plotter. The output is scan-converted
and suitable input to ‘lpr -v’.
/usr/lib/t300
/usr/lib/t300s
/usr/lib/t4014
/usr/lib/t450
/usr/lib/tek
/usr/lib/vplot
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWcsu
lp(1), vi(1), attributes(5)
tplot(1)
NAME
SYNOPSIS
DESCRIPTION
ENVIRONMENT
VARIABLES
FILES
ATTRIBUTES
SEE ALSO
User Commands 1559
tput – initialize a terminal or query terminfo database
tput [-T type] capname [parm…]
tput -S <<
tput uses the terminfo database to make the values of terminal-dependent
capabilities and information available to the shell (see sh(1)); to clear, initialize or reset
the terminal; or to return the long name of the requested terminal type. tput outputs
a string if the capability attribute (capname) is of type string, or an integer if the
attribute is of type integer. If the attribute is of type boolean, tput simply sets the exit
status (0 for TRUE if the terminal has the capability, 1 for FALSE if it does not), and
produces no output. Before using a value returned on standard output, the user
should test the exit status ($?, see sh(1)) to be sure it is 0. See the EXIT STATUS
section.
The following options are supported:
-Ttype Indicates the type of terminal. Normally this option is
unnecessary, because the default is taken from the environment
variable TERM.If-T is specified, then the shell variables LINES
and COLUMNS and the layer size will not be referenced.
-S Allows more than one capability per invocation of tput. The
capabilities must be passed to tput from the standard input
instead of from the command line (see the example in the
EXAMPLES section). Only one capname is allowed per line. The -S
option changes the meaning of the 0 and 1 boolean and string exit
statuses (see the EXIT STATUS section).
The following operands are supported:
capname Indicates the capability attribute from the terminfo database. See
terminfo(4) for a complete list of capabilities and the capname
associated with each.
The following strings will be supported as operands by the
implementation in the "C" locale:
clear Display the clear-screen sequence.
init If the terminfo database is present and an
entry for the user’s terminal exists (see -Ttype,
above), the following will occur:
1. if present, the terminal’s initialization
strings will be output (is1, is2, is3, if,
iprog),
2. any delays (for instance, newline) specified
in the entry will be set in the tty driver,
tput(1)
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
OPERANDS
1560 man pages section 1: User Commands • Last Revised 1 Feb 1995
3. tabs expansion will be turned on or off
according to the specification in the entry,
and
4. if tabs are not expanded, standard tabs will
be set (every 8 spaces). If an entry does not
contain the information needed for any of
the four above activities, that activity will
silently be skipped.
reset Instead of putting out initialization strings, the
terminal’s reset strings will be output if present
(rs1, rs2, rs3, rf). If the reset strings are not
present, but initialization strings are, the
initialization strings will be output. Otherwise,
reset acts identically to init.
longname If the terminfo database is present and an
entry for the user’s terminal exists (see -Ttype
above), then the long name of the terminal will
be put out. The long name is the last name in
the first line of the terminal’s description in the
terminfo database (see term(5)).
parm If the attribute is a string that takes parameters, the argument parm
will be instantiated into the string. An all numeric argument will
be passed to the attribute as a number.
EXAMPLE 1 Using the tput command.
This example initializes the terminal according to the type of terminal in the
environment variable TERM. This command should be included in everyone’s .profile
after the environment variable TERM has been exported, as illustrated on the
profile(4) manual page.
example% tput init
The next example resets an AT&T 5620 terminal, overriding the type of terminal in the
environment variable TERM:
example% tput -T5620 reset
The following example sends the sequence to move the cursor to row 0, column 0 (the
upper left corner of the screen, usually known as the "home" cursor position).
example% tput cup 0 0
The next example echos the clear-screen sequence for the current terminal.
example% tput clear
The next command prints the number of columns for the current terminal.
example% tput cols
The following command prints the number of columns for the 450 terminal.
tput(1)
EXAMPLES
User Commands 1561
EXAMPLE 1 Using the tput command. (Continued)
example% tput -T450 cols
The next example sets the shell variables bold, to begin stand-out mode sequence,
and offbold, to end standout mode sequence, for the current terminal. This might be
followed by a prompt:
echo "${bold}Please type in your name: ${offbold}\c"
example% bold=’tput smso’
example% offbold=’tput rmso’
This example sets the exit status to indicate if the current terminal is a hardcopy
terminal.
example% tput hc
This next example sends the sequence to move the cursor to row 23, column 4.
example% tput cup 23 4
The next command prints the long name from the terminfo database for the type of
terminal specified in the environment variable TERM.
example% tput longname
This last example shows tput processing several capabilities in one invocation. This
example clears the screen, moves the cursor to position 10, 10 and turns on bold (extra
bright) mode. The list is terminated by an exclamation mark (!) on a line by itself.
example% tput -S <<!
> clear
> cup 10 10
> bold
>!
See environ(5) for descriptions of the following environment variables that affect the
execution of tput: LC_CTYPE, LC_MESSAGES, and NLSPATH.
TERM Determine the terminal type. If this variable is unset or null, and if the -T
option is not specified, an unspecified default terminal type will be used.
The following exit values are returned:
0
■
If capname is of type boolean and -S is not specified, indicates TRUE.
■
If capname is of type string and -S is not specified, indicates capname is
defined for this terminal type.
■
If capname is of type boolean or string and -S is specified, indicates that
all lines were successful.
■
capname is of type integer.
■
The requested string was written successfully.
1
■
If capname is of type boolean and -S is not specified, indicates FALSE.
tput(1)
ENVIRONMENT
VARIABLES
EXIT STATUS
1562 man pages section 1: User Commands • Last Revised 1 Feb 1995
■
If capname is of type string and -S is not specified, indicates that
capname is not defined for this terminal type.
2 Usage error.
3 No information is available about the specified terminal type.
4 The specified operand is invalid.
>4 An error occurred.
−1 capname is a numeric variable that is not specified in the terminfo
database; for instance, tput -T450 lines and tput -T2621 xmc.
/usr/include/curses.h curses(3CURSES) header
/usr/include/term.h terminfo header
/usr/lib/tabset/* tab settings for some terminals, in a format
appropriate to be output to the terminal
(escape sequences that set margins and
tabs); for more information, see the "Tabs
and Initialization" section of terminfo(4)
/usr/share/lib/terminfo/?/* compiled terminal description database
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWcsu
clear(1), sh(1), stty(1), tabs(1), curses(3CURSES), profile(4), terminfo(4),
attributes(5), environ(5), term(5)
tput(1)
FILES
ATTRIBUTES
SEE ALSO
User Commands 1563
tr – translate characters
/usr/bin/tr [-cs] string1 string2
/usr/bin/tr -s | -d [-c] string1
/usr/bin/tr -ds [-c] string1 string2
/usr/xpg4/bin/tr [-cs] string1 string2
/usr/xpg4/bin/tr -s | -d [-c] string1
/usr/bin/xpg4/tr -ds [-c] string1 string2
The tr utility copies the standard input to the standard output with substitution or
deletion of selected characters. The options specified and the string1 and string2
operands control translations that occur while copying characters and single-character
collating elements.
The following options are supported:
-c Complements the set of characters specified by string1.
-d Deletes all occurrences of input characters that are specified by string1.
-s Replaces instances of repeated characters with a single character.
When the -d option is not specified:
■
Each input character found in the array specified by string1 is replaced by the
character in the same relative position in the array specified by string2. When the
array specified by string2 is shorter that the one specified by string1, the results are
unspecified.
■
If the -c option is specified, the complements of the characters specified by string1
(the set of all characters in the current character set, as defined by the current
setting of LC_CTYPE, except for those actually specified in the string1 operand) are
placed in the array in ascending collation sequence, as defined by the current
setting of LC_COLLATE.
■
Because the order in which characters specified by character class expressions or
equivalence class expressions is undefined, such expressions should only be used if
the intent is to map several characters into one. An exception is case conversion, as
described previously.
When the -d option is specified:
■
Input characters found in the array specified by string1 will be deleted.
■
When the -c option is specified with -d, all characters except those specified by
string1 will be deleted. The contents of string2 will be ignored, unless the -s option
is also specified.
■
The same string cannot be used for both the -d and the -s option; when both
options are specified, both string1 (used for deletion) and string2 (used for
squeezing) are required.
tr(1)
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
1564 man pages section 1: User Commands • Last Revised 1 Jun 2001
When the -s option is specified, after any deletions or translations have taken place,
repeated sequences of the same character will be replaced by one occurrence of the
same character, if the character is found in the array specified by the last operand. If
the last operand contains a character class, such as the following example:
tr -s ’[:space:]’
the last operand’s array will contain all of the characters in that character class.
However, in a case conversion, as described previously, such as
tr -s ’[:upper:]’’[:lower:]’
the last operand’s array will contain only those characters defined as the second
characters in each of the toupper or tolower character pairs, as appropriate. (See
toupper(3C) and tolower(3C)).
An empty string used for string1 or string2 produces undefined results.
The following operands are supported:
string1
string2 Translation control strings. Each string represents a set of
characters to be converted into an array of characters used for the
translation.
The operands string1 and string2 (if specified) define two arrays of characters. The
constructs in the following list can be used to specify characters or single-character
collating elements. If any of the constructs result in multi-character collating elements,
tr will exclude, without a diagnostic, those multi-character elements from the
resulting array.
character Any character not described by one of the conventions below
represents itself.
\ octal Octal sequences can be used to represent characters with specific
coded values. An octal sequence consists of a backslash followed
by the longest sequence of one-, two-, or three-octal-digit
characters (01234567). The sequence causes the character whose
encoding is represented by the one-, two- or three-digit octal
integer to be placed into the array. Multi-byte characters require
multiple, concatenated escape sequences of this type, including the
leading \ for each byte.
\ character The backslash-escape sequences \a, \b, \f, \n, \r, \t, and \v are
supported. The results of using any other character, other than an
octal digit, following the backslash are unspecified.
tr(1)
OPERANDS
User Commands 1565
c-c
[ c-c ] Represents the range of collating elements between the range
endpoints, inclusive, as defined by the current setting of the
LC_COLLATE locale category. The starting endpoint must precede
the second endpoint in the current collation order. The characters
or collating elements in the range are placed in the array in
ascending collation sequence.
[:class:] Represents all characters belonging to the defined character class,
as defined by the current setting of the LC_CTYPE locale category.
The following character class names will be accepted when
specified in string1:
alnum blank digit lower punct upper
alpha cntrl graph print space xdigit
In addition, character class expressions of the form [:name:] are
recognized in those locales where the name keyword has been
given a charclass definition in the LC_CTYPE category.
Note: /usr/bin/tr supports character class expressions only in
singlebyte locales. Use /usr/xpg4/bin/tr to support these
expressions in any locale.
When both the -d and -s options are specified, any of the
character class names will be accepted in string2. Otherwise, only
character class names lower or upper are valid in string2 and
then only if the corresponding character class upper and lower,
respectively, is specified in the same relative position in string1.
Such a specification is interpreted as a request for case conversion.
When [:lower:] appears in string1 and [:upper:] appears in
string2, the arrays will contain the characters from the toupper
mapping in the LC_CTYPE category of the current locale. When
[:upper:] appears in string1 and [:lower:] appears in string2,
the arrays will contain the characters from the tolower mapping
in the LC_CTYPE category of the current locale. The first character
from each mapping pair will be in the array for string1 and the
second character from each mapping pair will be in the array for
string2 in the same relative position.
Except for case conversion, the characters specified by a character
class expression are placed in the array in an unspecified order.
If the name specified for class does not define a valid character
class in the current locale, the behavior is undefined.
[=equiv=] Represents all characters or collating elements belonging to the
same equivalence class as equiv,asdefined by the current setting of
the LC_COLLATE locale category. An equivalence class expression
tr(1)
/usr/xpg4/bin/tr
/usr/bin/tr
1566 man pages section 1: User Commands • Last Revised 1 Jun 2001
is allowed only in string1,orinstring2 when it is being used by the
combined -d and -s options. The characters belonging to the
equivalence class are placed in the array in an unspecified order.
[x*n] Represents n repeated occurrences of the character x. Because this
expression is used to map multiple characters to one, it is only
valid when it occurs in string2.Ifn is omitted or is 0,itis
interpreted as large enough to extend the string2-based sequence
to the length of the string1-based sequence. If n has a leading 0,it
is interpreted as an octal value. Otherwise, it is interpreted as a
decimal value.
See largefile(5) for the description of the behavior of tr when encountering files
greater than or equal to 2 Gbyte ( 2
31
bytes).
EXAMPLE 1 Creating a list of words
The following example creates a list of all words in file1, one per line in file2, where a
word is taken to be a maximal string of letters.
tr −cs "[:alpha:]" "[\n*]" <file1 >file2
EXAMPLE 2 Translating characters
This example translates all lower-case characters in file1 to upper-case and writes
the results to standard output.
tr "[:lower:]" "[:upper:]" <file1
Notice that the caveat expressed in the corresponding example in XPG3 is no longer in
effect. This case conversion is now a special case that employs the tolower and
toupper classifications, ensuring that proper mapping is accomplished (when the
locale is correctly defined).
EXAMPLE 3 Identifying equivalent characters
This example uses an equivalence class to identify accented variants of the base
character e in file1, which are stripped of diacritical marks and written to file2.
tr "[=e=]" e <file1 >file2
See environ(5) for descriptions of the following environment variables that affect the
execution of tr: LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following exit values are returned:
0 All input was processed successfully.
>0 An error occurred.
tr(1)
USAGE
EXAMPLES
ENVIRONMENT
VARIABLES
EXIT STATUS
User Commands 1567
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWcsu
CSI Not enabled
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWxcu4
CSI Enabled
ed(1), sed(1), sh(1), tolower(3C), toupper(3C), ascii(5), attributes(5),
environ(5), largefile(5), XPG4(5)
Unlike some previous versions, /usr/xpg4/bin/tr correctly processes NUL
characters in its input stream. NUL characters can be stripped by using tr -d
’\000’.
tr(1)
ATTRIBUTES
/usr/bin/tr
/usr/xpg4/bin/tr
SEE ALSO
NOTES
1568 man pages section 1: User Commands • Last Revised 1 Jun 2001
tr – translate characters
/usr/ucb/tr [-cds] [string1 [string2]]
The tr utility copies the standard input to the standard output with substitution or
deletion of selected characters. The arguments string1 and string2 are considered sets
of characters. Any input character found in string1 is mapped into the character in the
corresponding position within string2. When string2 is short, it is padded to the length
of string1 by duplicating its last character.
In either string the notation:
a−b
denotes a range of characters from a to b in increasing ASCII order. The character \ ,
followed by 1, 2 or 3 octal digits stands for the character whose ASCII code is given by
those digits. As with the shell, the escape character \ , followed by any other
character, escapes any special meaning for that character.
Any combination of the options -c, -d,or-s may be used:
-c Complement the set of characters in string1 with respect to the universe of
characters whose ASCII codes are 01 through 0377 octal.
-d Delete all input characters in string1.
-s Squeeze all strings of repeated output characters that are in string2 to single
characters.
EXAMPLE 1 Creating a list of all the words in a filename
The following example creates a list of all the words in filename1, one per line, in
filename2, where a word is taken to be a maximal string of alphabetics. The second
string is quoted to protect ‘ \ ’ from the shell. 012 is the ASCII code for NEWLINE.
example% tr -cs A−Za−z ’\012’ < filename1> filename2
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWscpu
ed(1), ascii(5), attributes(5)
Will not handle ASCII NUL in string1 or string2. tr always deletes NUL from input.
tr(1B)
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXAMPLES
ATTRIBUTES
SEE ALSO
NOTES
User Commands 1569
trap, onintr – shell built-in functions to respond to (hardware) signals
trap [argument n [n2…]]
onintr [-| label]
*trap [arg sig [sig2…]]
The trap command argument is to be read and executed when the shell receives
numeric or symbolic signal(s) (n). (Note: argument is scanned once when the trap is set
and once when the trap is taken.) Trap commands are executed in order of signal
number or corresponding symbolic names. Any attempt to set a trap on a signal that
was ignored on entry to the current shell is ineffective. An attempt to trap on signal 11
(memory fault) produces an error. If argument is absent all trap(s) n are reset to their
original values. If argument is the null string this signal is ignored by the shell and by
the commands it invokes. If n is 0 the command argument is executed on exit from the
shell. The trap command with no arguments prints a list of commands associated
with each signal number.
onintr controls the action of the shell on interrupts. With no arguments, onintr
restores the default action of the shell on interrupts. (The shell terminates shell scripts
and returns to the terminal command input level). With the − argument, the shell
ignores all interrupts. With a label argument, the shell executes a goto label when an
interrupt is received or a child process terminates because it was interrupted.
trap uses arg as a command to be read and executed when the shell receives signal(s)
sig. (Note that arg is scanned once when the trap is set and once when the trap is
taken.) Each sig can be given as a number or as the name of the signal. trap
commands are executed in order of signal number. Any attempt to set a trap on a
signal that was ignored on entry to the current shell is ineffective. If arg is omitted or is
−, then the trap(s) for each sig are reset to their original values. If arg is the null (the
empty string, e.g., "" ) string then this signal is ignored by the shell and by the
commands it invokes. If sig is ERR then arg will be executed whenever a command has
a non-zero exit status. If sig is DEBUG then arg will be executed after each command. If
sig is 0 or EXIT for a trap set outside any function then the command arg is executed
on exit from the shell. The trap command with no arguments prints a list of
commands associated with each signal number.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are
treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the
command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable
assignment, are expanded with the same rules as a variable assignment. This
means that tilde substitution is performed after the = sign and word splitting and
file name generation are not performed.
trap(1)
NAME
sh
csh
ksh
sh
csh
ksh
1570 man pages section 1: User Commands • Last Revised 23 Oct 1994
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWcsu
csh(1), exit(1), ksh(1), sh(1), attributes(5)
trap(1)
ATTRIBUTES
SEE ALSO
User Commands 1571
troff – typeset or format documents
troff [-a] [-f] [-Fdir] [-i] [-mname] [-nN] [-olist] [-raN] [-sN]
[-Tdest] [-uN] [-z] [filename…]
troff formats text in the filenames for typesetting or laser printing. Input to troff is
expected to consist of text interspersed with formatting requests and macros. If no
filename argument is present, troff reads standard input. A minus sign (−)asa
filename indicates that standard input should be read at that point in the list of input
files.
The output of troff is usually piped through dpost(1) to create a printable
postscript file (see EXAMPLES).
The following options are supported. They may appear in any order, but all must
appear before the first filename.
-a Send an ASCII approximation of formatted output to standard
output. (Note: a rough ASCII version can also be printed out on
ordinary terminals with an old and rarely used command,
/usr/bin/ta.)
-f Do not print a trailer after the final page of output or cause the
postprocessor to relinquish control of the device.
-Fdir Search directory dir for font width or terminal tables instead of the
system default directory.
-i Read standard input after all input files are exhausted.
-mname Prepend the macro file /usr/share/lib/tmac/name to the
input filenames. Note: most references to macro packages include
the leading m as part of the name; for example, the man(5) macros
reside in /usr/share/lib/tmac/an. The macro directory can
be changed by setting the TROFFMACS environment variable to a
specific path. Be certain to include the trailing ’ / ’ (slash) at the
end of the path.
-nN Number the first generated page N.
-olist Print only pages whose page numbers appear in the
comma-separated list of numbers and ranges. A range N−M means
pages N through M; an initial −N means from the beginning to
page N; and a final N− means from N to the end.
-q Quiet mode in nroff; ignored in troff.
-raN Set register a (one-character names only) to N.
-sN Stop the phototypesetter every N pages. On some devices, troff
produces a trailer so you can change cassettes; resume by pressing
the typesetter’s start button.
troff(1)
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
1572 man pages section 1: User Commands • Last Revised 22 Jul 1998
-Tdest Prepare output for typesetter dest. The following values can be
supplied for dest:
post A PostScript printer; this is the default value. The
output of the -T option must go through dpost(1)
before it is sent to a PostScript printer to obtain the
proper output.
aps Autologic APS-5.
-uN Set the emboldening factor for the font mounted in position 3 to N.
If N is missing, then set the emboldening factor to 0.
-z Suppress formatted output. Only diagnostic messages and
messages output using the .tm request are output.
The following operand is supported:
filename The file containing text to be processed by troff.
EXAMPLE 1 Using troff
The following example shows how to print an input text file mytext, coded with
formatting requests and macros. The input file contains equations and tables and must
go through the tbl(1) and eqn(1) preprocessors before it is formatted by troff with
ms macros, processed by dpost(1), and printed by lp(1):
tbl mytext | eqn | troff -ms | dpost | lp
/tmp/trtmp temporary file
/usr/share/lib/tmac/* standard macro files
/usr/lib/font/* font width tables for alternate mounted
troff fonts
/usr/share/lib/nterm/* terminal driving tables for nroff
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWdoc
checknr(1), col(1), dpost(1), eqn(1), lp(1), man(1), nroff( 1), tbl(1),
attributes(5), man(5), me(5), ms(5)
troff is not 8-bit clean because it is by design based on 7-bit ASCII.
troff(1)
OPERANDS
EXAMPLES
FILES
ATTRIBUTES
SEE ALSO
NOTES
User Commands 1573
Previous documentation incorrectly described the numeric register yr as being the
"Last two digits of current year". yr is in actuality the number of years since 1900. To
correctly obtain the last two digits of the current year through the year 2099, the
definition given below of string register yy may be included in a document and
subsequently used to display a two-digit year. Note that any other available one- or
two-character register name may be substituted for yy.
.\" definition of new string register yy last two digits of year
.\" use yr (# of years since 1900) if it is < 100
.ie \n(yr<100 .ds yy \n(yr
.el \{ .\" else, subtract 100 from yr, store in ny
.nr ny \n(yr-100
.ie \n(ny>9 \{ .\" use ny if it is two digits
.ds yy \n(ny
.\" remove temporary number register ny
.rr ny \}
.el \{.ds yy 0
.\" if ny is one digit, append it to 0
.as yy \n(ny
.rr ny \} \}
troff(1)
1574 man pages section 1: User Commands • Last Revised 22 Jul 1998
true, false – provide truth values
true
false
true does nothing, successfully. false does nothing, unsuccessfully. They are
typically used in a shell script sh as:
while true
do
command
done
which executes command forever.
true has exit status 0.
false always will exit with a non-zero value.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWcsu
sh(1), attributes(5)
true(1)
NAME
SYNOPSIS
DESCRIPTION
EXIT STATUS
ATTRIBUTES
SEE ALSO
User Commands 1575
truss – trace system calls and signals
truss [-fcaeildD] [- [tTvx] [!] syscall ,…] [- [sS] [!] signal ,…][-
[mM] [!] fault ,…] [- [rw] [!] fd ,…] [- [uU] [!] lib ,… : [:] [!]
func ,…] [-o outfile]command |-ppid…
The truss utility executes the specified command and produces a trace of the system
calls it performs, the signals it receives, and the machine faults it incurs. Each line of
the trace output reports either the fault or signal name or the system call name with its
arguments and return value(s). System call arguments are displayed symbolically
when possible using defines from relevant system headers; for any path name pointer
argument, the pointed-to string is displayed. Error returns are reported using the error
code names described in intro(3).
Optionally (see the -u option), truss will also produce an entry/exit trace of
user-level function calls executed by the traced process, indented to indicate nesting.
The following options are recognized. For those options that take a list argument, the
name all can be used as a shorthand to specify all possible members of the list. If the
list begins with a !, the meaning of the option is negated (for example, exclude rather
than trace). Multiple occurrences of the same option may be specified. For the same
name in a list, subsequent options (those to the right) override previous ones (those to
the left).
-p
Interprets the command arguments to truss as a list of process-ids for existing
processes (see ps(1)) rather than as a command to be executed. truss takes control
of each process and begins tracing it provided that the userid and groupid of the
process match those of the user or that the user is a privileged user. Processes may
also be specified by their names in the /proc directory, for example,
/proc/12345.
-f
Follows all children created by fork() or vfork() and includes their signals,
faults, and system calls in the trace output. Normally, only the first-level command
or process is traced. When -f is specified, the process-id is included with each line
of trace output to indicate which process executed the system call or received the
signal.
-c
Counts traced system calls, faults, and signals rather than displaying the trace
line-by-line. A summary report is produced after the traced command terminates or
when truss is interrupted. If -f is also specified, the counts include all traced
system calls, faults, and signals for child processes.
-a
Shows the argument strings that are passed in each exec() system call.
-e
Shows the environment strings that are passed in each exec() system call.
truss(1)
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
1576 man pages section 1: User Commands • Last Revised 15 Jul 1998
-i
Do not display interruptible sleeping system calls. Certain system calls, such as
open() and read() on terminal devices or pipes, can sleep for indefinite periods
and are interruptible. Normally, truss reports such sleeping system calls if they
remain asleep for more than one second. The system call is reported again a second
time when it completes. The -i option causes such system calls to be reported only
once, when they complete.
-l
Includes the id of the responsible lightweight process (LWP) with each line of trace
output. If -f is also specified, both the process-id and the LWP-id are included.
-d
Includes a time stamp on each line of trace output. The time stamp appears as a
field containing seconds . fraction at the start of the line. This represents a time in
seconds relative to the beginning of the trace. The first line of the trace output will
show the base time from which the individual time stamps are measured, both as
seconds since the epoch (see time(2)) and as a date string (see ctime(3C) and
date(1)). The times that are reported are the times that the event in question
occurred. For all system calls, the event is the completion of the system call, not the
start of the system call.
-D
Includes a time delta on each line of trace output. The value appears as a field
containing seconds . fraction and represents the elapsed time for the LWP that
incurred the event since the last reported event incurred by that LWP. Specifically,
for system calls, this is not the time spent within the system call.
-t [!]syscall,
System calls to trace or exclude. Those system calls specified in the
comma-separated list are traced. If the list begins with a !, the specified system
calls are excluded from the trace output. Default is -tall.
-T [!]syscall,
System calls that stop the process. The specified system calls are added to the set
specified by -t. If one of the specified system calls is encountered, truss leaves
the process stopped and abandoned. That is, truss releases the process and exits
but leaves the process in the stopped state at completion of the system call in
question. A debugger or other process inspection tool (see proc(1)) can then be
applied to the stopped process. truss can be reapplied to the stopped process with
the same or different options to continue tracing. Default is -T!all.
A process left stopped in this manner cannot be restarted by the application of
kill -CONT because it is stopped on an event of interest via /proc, not by the
default action of a stopping signal (see signal(3HEAD)). The prun(1) command
described in proc(1) can be used to set the stopped process running again.
-v [!]syscall,
Verbose. Displays the contents of any structures passed by address to the specified
system calls (if traced by -t). Input values as well as values returned by the
truss(1)
User Commands 1577
operating system are shown. For any field used as both input and output, only the
output value is shown. Default is -v!all.
-x [!]syscall,
Displays the arguments to the specified system calls (if traced by -t) in raw form,
usually hexadecimal, rather than symbolically. This is for unredeemed hackers who
must see the raw bits to be happy. Default is -x!all.
-s [!]signal,
Signals to trace or exclude. Those signals specified in the comma-separated list are
traced. The trace output reports the receipt of each specified signal, even if the
signal is being ignored (not blocked). (Blocked signals are not received until they
are unblocked.) Signals may be specified by name or number (see
<sys/signal.h>). If the list begins with a !, the specified signals are excluded
from the trace output. Default is -sall.
-S [!]signal,
Signals that stop the process. The specified signals are added to the set specified by
-s. If one of the specified signals is received, truss leaves the process stopped and
abandoned (see the -T option). Default is -S!all.
-m [!]fault,
Machine faults to trace or exclude. Those faults specified in the comma-separated
list are traced. Faults may be specified by name or number (see <sys/fault.h>).
If the list begins with a !, the specified faults are excluded from the trace output.
Default is -mall -m!fltpage.
-M [!]fault,
Machine faults that stop the process. The specified faults are added to the set
specified by -m. If one of the specified faults is incurred, truss leaves the process
stopped and abandoned (see the -T option). Default is -M!all.
-r [!]fd,
Shows the full contents of the I/O buffer for each read() on any of the specified
file descriptors. The output is formatted 32 bytes per line and shows each byte as an
ASCII character (preceded by one blank) or as a 2-character C language escape
sequence for control characters such as horizontal tab ( \ t) and newline ( \ n). If
ASCII interpretation is not possible, the byte is shown in 2-character hexadecimal
representation. (The first 12 bytes of the I/O buffer for each traced read() are
shown even in the absence of -r.) Default is -r!all.
-w [!]fd,
Shows the contents of the I/O buffer for each write() on any of the specified file
descriptors (see the -r option). Default is -w!all.
-u [!]lib, :[:][!]func,
User-level function call tracing. lib, isacomma-separated list of dynamic library
names, excluding the ‘‘.so.n’’ suffix. func, isacomma-separated list of function
names. In both cases the names can include name-matching metacharacters *,?,[]
with the same meanings as those of sh(1) but as applied to the library/function
name spaces, not to files. An empty library or function list defaults to *, trace all
libraries or functions in a library. A leading ! on either list specifies an exclusion
truss(1)
1578 man pages section 1: User Commands • Last Revised 15 Jul 1998
list, names of libraries or functions not to be traced. Excluding a library excludes all
functions in that library; any function list following a library exclusion list is
ignored.
A single : separating the library list from the function list means to trace calls into
the libraries from outside the libraries, but omit calls made to functions in a library
from other functions in the same library. A double ::means to trace all calls,
regardless of origin.
Library patterns do not match either the executable file or the dynamic linker
unless there is an exact match (l* will not match ld.so.1). To trace functions in
either of these objects, the names must be specified exactly, as in: truss -u a.out
-u ld a.out is the literal name to be used for this purpose; it does not stand
for the name of the executable file. Tracing a.out function calls implies all calls
(default is ::).
Multiple -u options may be specified and they are honored left-to-right. If the
process is linked with -lthread, the id of the thread that performed the function
call is included in the trace output for the call. truss searches the dynamic symbol
table in each library to find function names and will also search the standard
symbol table if it has not been stripped.
-U [!]lib, :[:][!]func,
User-level function calls that stop the process. The specified functions are added to
the set specified by -u. If one of the specified functions is called, truss leaves the
process stopped and abandoned (see the -T option).
-o outfile
File to be used for the trace output. By default, the output goes to standard error.
See man pages section 2: System Calls for system call names accepted by the -t, -T, -v,
and -x options. System call numbers are also accepted.
If truss is used to initiate and trace a specified command and if the -o option is used
or if standard error is redirected to a non-terminal file, then truss runs with hangup,
interrupt, and quit signals ignored. This facilitates tracing of interactive programs that
catch interrupt and quit signals from the terminal.
If the trace output remains directed to the terminal, or if existing processes are traced
(the -p option), then truss responds to hangup, interrupt, and quit signals by
releasing all traced processes and exiting. This enables the user to terminate excessive
trace output and to release previously-existing processes. Released processes continue
normally, as though they had never been touched.
EXAMPLE 1 Tracing a command
This example produces a trace of the find(1) command on the terminal:
example$ truss find . -print >find.out
truss(1)
EXAMPLES
User Commands 1579
EXAMPLE 1 Tracing a command (Continued)
EXAMPLE 2 Tracing common system calls
To see only a trace of the open, close, read, and write system calls:
example$ truss -t open,close,read,write find . -print >find.out
EXAMPLE 3 Tracing a shell script
This produces a trace of the spell(1) command on the file truss.out:
example$ truss -f -o truss.out spell document
spell is a shell script, so the -f flag is needed to trace not only the shell but also the
processes created by the shell. (The spell script runs a pipeline of eight processes.)
EXAMPLE 4 Abbreviating output
A particularly boring example is:
example$ truss nroff -mm document >nroff.out
because 97% of the output reports lseek(), read(), and write() system calls. To
abbreviate it:
example$ truss -t ! lseek,read,write nroff -mm document >nroff.out
EXAMPLE 5 Tracing library calls from outside the C library
This example traces all user-level calls made to any function in the C library from
outside the C library:
example$ truss -u libc . . .
EXAMPLE 6 Tracing library calls from within the C library
This example includes calls made to functions in the C library from within the C
library itself:
example$ truss -u libc::
EXAMPLE 7 Tracing library calls other than the C library
This example traces all user-level calls made to any library other than the C library:
example$ truss -u ’*’ -u !libc . . .
EXAMPLE 8 Tracing printf and scanf function calls
This example traces all user-level calls to functions in the printf and scanf family
contained in the C library:
truss(1)
1580 man pages section 1: User Commands • Last Revised 15 Jul 1998
EXAMPLE 8 Tracing printf and scanf function calls (Continued)
example$ truss -u ’libc : *printf,*scanf’
EXAMPLE 9 Tracing any user-level function call
This example traces every user-level function call from anywhere to anywhere:
example$ truss -u a.out -u ld::-u ::
EXAMPLE 10 Tracing a system call verbosely
This example verbosely traces the system call activity of process #1, init(1M) (if you
are a privileged user):
example# truss -p -v all 1
Interrupting truss returns init to normal operation.
/proc/* process files
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
Availability SUNWtoo (32-bit)
SUNWtoox (64-bit)
date(1), find(1), proc(1), ps(1), sh(1), spell(1), init (1M), intro(3), exec(2),
fork(2), lseek(2), open(2), read(2), time(2), vfork(2), write(2), ctime(3C),
threads(3THR), proc(4), attributes(5), signal(3HEAD)
man pages section 2: System Calls
Some of the system calls described in man pages section 2: System Calls differ from the
actual operating system interfaces. Do not be surprised by minor deviations of the
trace output from the descriptions in that document.
Every machine fault (except a page fault) results in the posting of a signal to the LWP
that incurred the fault. A report of a received signal will immediately follow each
report of a machine fault (except a page fault) unless that signal is being blocked.
The operating system enforces certain security restrictions on the tracing of processes.
In particular, any command whose object file (a.out) cannot be read by a user cannot
be traced by that user; set-uid and set-gid commands can be traced only by a
privileged user. Unless it is run by a privileged user, truss loses control of any
process that performs an exec() of a set-id or unreadable object file; such processes
continue normally, though independently of truss, from the point of the exec().
truss(1)
FILES
ATTRIBUTES
SEE ALSO
NOTES
User Commands 1581
To avoid collisions with other controlling processes, truss will not trace a process
that it detects is being controlled by another process via the /proc interface. This
allows truss to be applied to proc(4)-based debuggers as well as to another instance
of itself.
The trace output contains tab characters under the assumption that standard tab stops
are set (every eight positions).
The trace output for multiple processes or for a multithreaded process (one that
contains more than one LWP) is not produced in strict time order. For example, a
read() on a pipe may be reported before the corresponding write(). For any one
LWP (a traditional process contains only one), the output is strictly time-ordered.
When tracing more than one process, truss runs as one controlling process for each
process being traced. For the example of the spell command shown above, spell
itself uses 9 process slots, one for the shell and 8 for the 8-member pipeline, while
truss adds another 9 processes, for a total of 18.
Not all possible structures passed in all possible system calls are displayed under the
-v option.
truss(1)
1582 man pages section 1: User Commands • Last Revised 15 Jul 1998