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
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).
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.
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.
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
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:
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).
/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:
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
-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)
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:
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.
-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
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
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
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