Tài liệu Unix Linux Reference - Pdf 84

- 1 -
AWK....................................................................................................................................4
BC.....................................................................................................................................11
CHGRP .............................................................................................................................16
CHMOD.............................................................................................................................19
CHOWN ............................................................................................................................26
CP .....................................................................................................................................29
CRON................................................................................................................................34
CSH...................................................................................................................................36
CUT...................................................................................................................................71
DATE ................................................................................................................................75
DF .....................................................................................................................................79
DIFF ..................................................................................................................................84
ENV...................................................................................................................................89
EXPR ................................................................................................................................92
FIND..................................................................................................................................96
GREP..............................................................................................................................104
KILL ................................................................................................................................111
KSH.................................................................................................................................116
LN ...................................................................................................................................181
LS....................................................................................................................................186
- 2 -
MAKE..............................................................................................................................194
MAN................................................................................................................................234
MORE .............................................................................................................................241
MV...................................................................................................................................251
NROFF............................................................................................................................254
OD...................................................................................................................................257
PRINTF ...........................................................................................................................265
PS ...................................................................................................................................271
REGEXP .........................................................................................................................283

prog string must be enclosed in single quotes (') to protect
it from the shell. For each pattern in prog there may be an
associated action performed when a line of a filename
matches the pattern. The set of pattern-action statements
may appear literally as prog or in a file specified with the
-f progfile option. Input files are read in order; if there
are no files, the standard input is read. The file name '-'
means the standard input.
OPTIONS
-f progfile awk uses the set of patterns it reads from
progfile.
-Fc Use the character c as the field separator
(FS) character. See the discussion of FS
below.
USAGE
Input Lines
Each input line is matched against the pattern portion of
every pattern-action statement; the associated action is
performed for each matched pattern. Any filename of the
form var=value is treated as an assignment, not a filename,
and is executed at the time it would have been opened if it
were a filename. Variables assigned in this manner are not
available inside a BEGIN rule, and are assigned after previ-
- 5 -
ously specified files have been read.
An input line is normally made up of fields separated by
white spaces. (This default can be changed by using the FS
built-in variable or the -Fc option.) The default is to
ignore leading blanks and to separate fields by blanks
and/or tab characters. However, if FS is assigned a value

The special patterns BEGIN and END may be used to capture
- 6 -
control before the first input line has been read and after
the last input line has been read respectively. These key-
words do not combine with any other patterns.
Built-in Variables
Built-in variables include:
FILENAME name of the current input file
FS input field separator regular expression
(default blank and tab)
NF number of fields in the current record
NR ordinal number of the current record
OFMT output format for numbers (default %.6g)
OFS output field separator (default blank)
ORS output record separator (default new-
line)
RS input record separator (default new-
line)
An action is a sequence of statements. A statement may be
one of the following:
if ( expression ) statement [ else statement ]
while ( expression ) statement
do statement while ( expression )
for ( expression ; expression ; expression ) statement
for ( var in array ) statement
break
continue
{ [ statement ] ... }
expression # commonly variable = expression
print [ expression-list ] [ >expression ]

log(x) Return the natural logarithm of x.
sqrt(x) Return the square root of x.
int(x) Truncate its argument to an integer. It
will be truncated toward 0 whenx>0.
The string functions are as follows:
index(s, t) Return the position in string s where
string t first occurs, or 0 if it does
not occur at all.
int(s) truncates s to an integer value. If s
is not specified, $0 is used.
length(s) Return the length of its argument taken
as a string, or of the whole line if
there is no argument.
- 8 -
match(s, re) Return the position in string s where
the regular expression re occurs, or 0
if it does not occur at all.
split(s, a, fs)
Split the string s into array elements
a[1], a[2], a[n], and returns n. The
separation is done with the regular
expression fs or with the field separa-
tor FS if fs is not given.
sprintf(fmt, expr, expr,...)
Format the expressions according to the
printf(3S) format given by fmt and
returns the resulting string.
substr(s, m, n)
returns the n-character substring of s
that begins at position m.

/Page/ { $2 = n++; }
{ print }
Assuming this program is in a file named prog, the following
command line prints the file input numbering its pages
starting at 5: awk -f prog n=5 input.
ENVIRONMENT
See environ(5) for descriptions of the following environment
variables that affect the execution of awk: LC_CTYPE and
LC_MESSAGES.
ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
/usr/bin/awk
__________________________________
| ATTRIBUTE TYPE| ATTRIBUTE VALUE|
|_______________|_________________|
| Availability | SUNWesu |
| CSI | Enabled |
|_______________|_________________|
/usr/xpg4/bin/awk
__________________________________
| ATTRIBUTE TYPE| ATTRIBUTE VALUE|
- 10 -
|_______________|_________________|
| Availability | SUNWxcu4 |
| CSI | Enabled |
|_______________|_________________|
SEE ALSO
egrep(1), grep(1), nawk(1), sed(1), printf(3S), attri-
butes(5), environ(5), largefile(5), xpg4(5)

S means a statement.
Comments
Enclosed in /* and */.
Names (Operands)
Simple variables: L.
Array elements: L [ E ] (up to BC_DIM_MAX dimen-
sions).
The words ibase, obase (limited to BC_BASE_MAX), and
scale (limited to BC_SCALE_MAX).
Other Operands
Arbitrarily long numbers with optional sign and
decimal point.
- 12 -
Strings of fewer than BC_STRING_MAX characters,
between double quotes (").
(E)
sqrt(E) Square root
length(E) Number of significant
decimal digits.
scale(E) Number of digits right
of decimal point.
L(E,...,E)
Operators
+-*/%^ (%isremainder; ^ is
power)
++ -- (prefix and postfix;
apply to names)
== <= >= != < >
==+=-=*=/=%=^
Statements

tively.
The same letter may be used as an array, a function, and a
simple variable simultaneously. All variables are global to
the program. auto variables are stacked during function
calls. When using arrays as function arguments or defining
them as automatic variables, empty square brackets must fol-
low the array name.
OPTIONS
-c Compile only. The output is dc commands that are
sent to the standard output.
-l Define the math functions and initialize scale to
20, instead of the default zero.
OPERANDS
The following operands are supported:
file A pathname of a text file containing bc program
statements. After all cases of file have been read,
bc will read the standard input.
EXAMPLES
In the shell, the following assigns an approximation of the
first ten digits of -n to the variable x :
x=$(printf "%s\n" 'scale = 10; 104348/33215' | bc)
Defines a function to compute an approximate value of the
exponential function:
scale = 20
define e(x){
auto a, b, c, i, s
- 14 -
a=1
b=1
s=1

|_______________|_________________|
| Availability | SUNWesu |
|_______________|_________________|
- 15 -
SEE ALSO
dc(1), awk(1), attributes(5)
NOTES
The bc command does not recognize the logical operators &&
and ||.
The for statement must have all three expressions (E's).
- 16 -
chgrp
chgrp - change file group ownership
SYNOPSIS
chgrp [ -fhR ] group file
DESCRIPTION
The chgrp utility will set the group ID of the file named by
each file operand to the group ID specified by the group
operand.
For each file operand, it will perform actions equivalent to
the chown(2) function, called with the following arguments:
o The file operand will be used as the path argument.
o The user ID of the file will be used as the owner argu-
ment.
o The specified group ID will be used as the group argu-
ment.
Unless chgrp is invoked by a process with appropriate
privileges, the set-user-ID and set-group-ID bits of a regu-
lar file will be cleared upon successful completion; the
set-user-ID and set-group-ID bits of other file types may be

group A group name from the group database or a numeric
group ID. Either specifies a group ID to be given
to each file named by one of the file operands. If
a numeric group operand exists in the group database
as a group name, the group ID number associated with
that group name is used as the group ID.
file A path name of a file whose group ID is to be modi-
fied.
USAGE
See largefile(5) for the description of the behavior of
chgrp when encountering files greater than or equal to 2
Gbyte (2**31 bytes).
ENVIRONMENT
See environ(5) for descriptions of the following environment
variables that affect the execution of chgrp: LC_CTYPE,
LC_MESSAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 The utility executed successfully and all requested
changes were made.
>0 An error occurred.
- 18 -
FILES
/etc/group group file
ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
______________________________________
| ATTRIBUTE TYPE| ATTRIBUTE VALUE |
|_______________|_____________________|

4, 2, or 0.
For directories, files are created
with BSD semantics for propagation
of the group ID. With this option,
files and subdirectories created in
the directory inherit the group ID
of the directory, rather than of
the current process. It may be
cleared only by using symbolic
mode.
1000 Turn on sticky bit. See chmod(2).
0400 Allow read by owner.
0200 Allow write by owner.
0100 Allow execute (search in directory)
by owner.
0700 Allow read, write, and execute
- 20 -
(search) by owner.
0040 Allow read by group.
0020 Allow write by group.
0010 Allow execute (search in directory)
by group.
0070 Allow read, write, and execute
(search) by group.
0004 Allow read by others.
0002 Allow write by others.
0001 Allow execute (search in directory)
by others.
0007 Allow read, write, and execute
(search) by others.

+ Add permissions.
If permissions is omitted, nothing
is added.
If who is omitted, add the file
mode bits represented by permis-
sions, except for the those with
corresponding bits in the file mode
creation mask.
If who is present, add the file
mode bits represented by the per-
missions.
- Take away permissions.
If permissions is omitted, do noth-
ing.
If who is omitted, clear the file
mode bits represented by permis-
sions, except for those with
corresponding bits in the file mode
creation mask.
If who is present, clear the file
mode bits represented by permis-
sions.
= Assign permissions absolutely.
If who is omitted, clear all file
mode bits; if who is present, clear
the file mode bits represented by
who.
If permissions is omitted, do noth-
ing else.
If who is omitted, add the file

User Group Other
rwx rwx rwx
This example (user, group, and others all
have permission to read, write, and execute a
given file) demonstrates two categories for
granting permissions: the access class and
the permissions themselves.
The letter s is only meaningful with u or g,
and t only works with u.
Mandatory file and record locking (l) refers
- 23 -
to a file's ability to have its reading or
writing permissions locked while a program is
accessing that file.
In a directory which has the set-group-ID bit
set (reflected as either -----s--- or -----
l--- in the output of 'ls -ld'), files and
subdirectories are created with the group-ID
of the parent directory-not that of current
process.
It is not possible to permit group execution
and enable a file to be locked on execution
at the same time. In addition, it is not
possible to turn on the set-group-ID bit and
enable a file to be locked on execution at
the same time. The following examples,
therefore, are invalid and elicit error mes-
sages:
chmod g+x,+l file
chmod g+s,+l file

EXAMPLES
Deny execute permission to everyone:
example% chmod a-x file
Allow only read permission to everyone:
example% chmod 444 file
Make a file readable and writable by the group and others:
example% chmod go+rw file
example% chmod 066 file
Cause a file to be locked during access:
example% chmod +l file
Allow everyone to read, write, and execute the file and turn
on the set group-ID.
example% chmod a=rwx,g+s file
example% chmod 2777 file
ENVIRONMENT
See environ(5) for descriptions of the following environment
variables that affect the execution of chmod: LC_CTYPE,
LC_MESSAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
- 25 -
0 Successful completion.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
__________________________________
| ATTRIBUTE TYPE| ATTRIBUTE VALUE|
|_______________|_________________|
| Availability | SUNWcsu |


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status