1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Unix Linux Reference ppt

374 417 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Tài liệu Unix Linux Reference ppt
Trường học University of Information Technology
Chuyên ngành Computer Science
Thể loại Tài liệu
Định dạng
Số trang 374
Dung lượng 629,1 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

OPERANDS The following operands are supported: a numeric group operand exists in the group database as a group name, the group ID number associated withthat group name is used as the gro

Trang 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

Trang 2

MAKE 194

MAN 234

MORE 241

MV 251

NROFF 254

OD 257

PRINTF 265

PS 271

REGEXP 283

RM 292

SCRIPT 297

SED 298

SHUTDOWN 309

SLEEP 312

SORT 314

SPELL 324

SUM 328

TAR 330

TR 342

TROFF 349

Trang 3

UNIQ 352

VI 355

WC 365

WHICH 367

WHO 370

Trang 4

/usr/xpg4/bin/awk [ -F ERE ] [ -v assignment ]

DESCRIPTION

manual page

The /usr/bin/awk utility scans each input filename for lines

prog string must be enclosed in single quotes (') to protect

may appear literally as prog or in a file specified with the

means the standard input

OPTIONS

progfile

below

USAGE

Input Lines

available inside a BEGIN rule, and are assigned after

Trang 5

previ-ously specified files have been read.

$0 refers to the entire line

Pattern-action Statements

A pattern-action statement has the form:

pattern { action }

Pattern-action statements are separated by newlines or colons

semi-Patterns are arbitrary Boolean combinations ( !, ||, &&, and

expression relop expressionexpression matchop regular_expression

rela-tional expression, the special expression

var in array

or a Boolean combination of these

the action is performed for all lines between the occurrence

pat-tern

Trang 6

control before the first input line has been read and after

key-words do not combine with any other patterns

Built-in Variables

Built-in variables include:

(default blank and tab)

new-line)

new-line)

one of the following:

if ( expression ) statement [ else statement ]while ( expression ) statement

do statement while ( expression )for ( expression ; expression ; expression ) statementfor ( var in array ) statement

breakcontinue{ [ statement ] }

print [ expression-list ] [ >expression ]printf format [ , expression-list ] [ >expression ]

is expr

Trang 7

%, ^ and concatenation (indicated by a blank) The

are quoted (""), with the usual C escapes recognized within

output, or on a file if >expression is present, or on a pipe

according to the format (see printf(3S))

Built-in Functions

The arithmetic functions are as follows:

radians

will be truncated toward 0 when x > 0.The string functions are as follows:

not occur at all

is not specified, $0 is used

there is no argument

Trang 8

match(s, re) Return the position in string s where

if it does not occur at all

split(s, a, fs)

separa-tor FS if fs is not given

sprintf(fmt, expr, expr, )

returns the resulting string

substr(s, m, n)

that begins at position m

The input/output function is as follows:

for successful input, 0 for end of file,and -1 for an error

Large File Behavior

(2**31 bytes)

EXAMPLES

Print lines longer than 72 characters:

length > 72Print first two fields in opposite order:

Trang 9

Add up first column, print sum and average:

{ s += $1 }

Print fields in reverse order:

{ for (i = NF; i > 0; i) print $i }Print all lines between start/stop pairs:

ENVIRONMENT

See environ(5) for descriptions of the following environment

Trang 10

attri-butes(5), environ(5), largefile(5), xpg4(5)

NOTES

involved

add 0 to it; to force it to be treated as a string ate the null string ("") to it

Trang 11

The bc utility implements an arbitrary precision calculator.

resem-bles C and is a preprocessor for the desk calculator program

stan-dard output instead

USAGE

The syntax for bc programs is as follows:

L means a letter a-z,

scale (limited to BC_SCALE_MAX)

Other Operands

decimal point

Trang 12

Strings of fewer than BC_STRING_MAX characters,between double quotes (").

breakquit.string

Functions in -l Math Library

Trang 13

l(x) log

All function arguments are passed by value

ibase or obase set the input and output number radix tively

them as automatic variables, empty square brackets must low the array name

fol-OPTIONS

sent to the standard output

20, instead of the default zero

OPERANDS

The following operands are supported:

bc will read the standard input

EXAMPLES

first ten digits of - n to the variable x :

x=$(printf "%s\n" 'scale = 10; 104348/33215' | bc)

exponential function:

scale = 20define e(x){

auto a, b, c, i, s

Trang 14

a = 1

b = 1

s = 1for(i=1; 1==1; i++){

a = a*x

b = b*i

c = a/bif(c == 0) return(s)

s = s+c}

See environ(5) for descriptions of the following environment

LC_MESSAGES, and NLSPATH

EXIT STATUS

The following exit values are returned:

unspecified An error occurred

FILES

Trang 16

The chgrp utility will set the group ID of the file named by

operand

For each file operand, it will perform actions equivalent tothe chown(2) function, called with the following arguments:

argu-ment

argu-ment

privileges, the set-user-ID and set-group-ID bits of a

set-user-ID and set-group-ID bits of other file types may becleared

sys-tem(4) and fpathconf(2)

Trang 17

OPTIONS

is changed

no recursion takes place

OPERANDS

The following operands are supported:

a numeric group operand exists in the group database

as a group name, the group ID number associated withthat group name is used as the group ID

modi-fied

USAGE

Gbyte (2**31 bytes)

ENVIRONMENT

See environ(5) for descriptions of the following environment

LC_MESSAGES, and NLSPATH

EXIT STATUS

The following exit values are returned:

changes were made

Trang 18

NOTES

chgrp is CSI-enabled except for the group name

Trang 19

chmod

chmod - change the permissions mode of a file

SYNOPSIS

chmod [ -fR ] <absolute-mode> file

chmod [ -fR ] <symbolic-mode-list> file

DESCRIPTION

mode may be absolute or symbolic

Absolute mode

An absolute mode is specified using octal numbers:

chmod nnnn file

where:

constructed from the OR of any of the ing modes:

7, 5, 3, or 1

Enable mandatory locking if # is 6,

4, 2, or 0

files and subdirectories created in

mode

by owner

Trang 20

(search) by owner.

by group

(search) by group

by others

(search) by others

Note that the setgid bit cannot be set (or cleared) in

using g+s (or g-s)

Symbolic mode

A symbolic mode specification has the following format:

chmod <symbolic-mode-list> file

the form:

[who] operator [permissions]

corresponding operations to be performed simultaneously

omitted, chmod will not override the

Trang 21

restric-tions of your user mask.

are to be changed:

is added

corresponding bits in the file modecreation mask

per-missions

If permissions is omitted, do ing

corresponding bits in the file modecreation mask

permis-sions

mode bits; if who is present, clear

who

If permissions is omitted, do ing else

Trang 22

permis-sions, except for the those withcorresponding bits in the file modecreation mask.

permis-sions

or other mode respectively

having three characters:

have permission to read, write, and execute a

the permissions themselves

and t only works with u

Trang 23

to a file's ability to have its reading orwriting permissions locked while a program isaccessing that file.

In a directory which has the set-group-ID bit

process

mes-sages:

chmod g+x,+l filechmod g+s,+l fileOnly the owner of a file or directory (or the

bit, your own group ID must correspond to thefile's and group execution must be set

OPTIONS

The following options are supported:

change the mode of a file

setting the mode for each file as described above

the target file is changed, but no recursion takesplace

OPERANDS

Trang 24

The following operands are supported:

operands; see DESCRIPTION

be modified

USAGE

Gbyte (2**31 bytes)

EXAMPLES

Deny execute permission to everyone:

example% chmod a-x fileAllow only read permission to everyone:

example% chmod 444 fileMake a file readable and writable by the group and others:

example% chmod go+rw fileexample% 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 fileexample% chmod 2777 file

ENVIRONMENT

See environ(5) for descriptions of the following environment

LC_MESSAGES, and NLSPATH

EXIT STATUS

The following exit values are returned:

Trang 25

manda-tory locking is meaningful.

execution is not allowed

Trang 26

option-ally, will set the group ID to that specified by group.

set-user-ID bit is cleared

owner of that file

include the following line in /etc/system:

set rstchown = 1

/etc/system:

set rstchown = 0

sys-tem(4) and fpathconf(2)

OPTIONS

The following options are supported:

Trang 27

file referenced by the symbolic link is changed.

option is specified), but no recursion takes place.OPERANDS

The following operands are supported:

speci-fies a user ID to be given to each file named

number associated with that user name will be

group operand exists in the group database as

group ID

modified

USAGE

Gbyte (2**31 bytes)

ENVIRONMENT

See environ(5) for descriptions of the following environment

LC_MESSAGES, and NLSPATH

EXIT STATUS

The following exit values are returned:

Trang 28

changes were made.

sys-tem(4), attributes(5), environ(5), largefile(5)

NOTES

chown is CSI-enabled except for the owner and group names

Trang 29

cp

cp - copy files

SYNOPSIS

/usr/bin/cp [-fip] source_file target_file

/usr/bin/cp [-fip] source_file target

/usr/bin/cp -r|-R [-fip] source_dir target

/usr/xpg4/bin/cp [-fip] source_file target_file

/usr/xpg4/bin/cp [-fip] source_file target

/usr/xpg4/bin/cp -r|-R [-fip] source_dir target

DESCRIPTION

target_file becomes a new file

either does not exist or is not a directory

source_dir, cp will copy all files and subdirectories

Trang 30

OPTIONS

The following options are supported for both /usr/bin/cp and/usr/xpg4/bin/cp:

destina-tion file and proceed

other answer prevents cp from overwriting target

to target

from

/usr/bin/cp

The following option is supported for /usr/bin/cp only:

source_file, but also preserves the owner and group id,

fail, and it will clear S_ISUID and S_ISGID bits in the

these bits

In order to preserve the owner and group id, permission

destination file

/usr/xpg4/bin/cp

The following option is supported for /usr/xpg4/bin/cp only:

source_file, but also preserves the owner and group id,

Trang 31

permission modes, modification and access time, and

diagnostic message to stderr and return a non-zero exit

to clear these bits

In order to preserve the owner and group id, permission

destination file

OPERANDS

The following operands are supported:

is copied

copied files

USAGE

Trang 32

example% cp ~/src/* /tmp

existing destination directory:

example% ls ~/bkup/usr/example/fred/bkup not foundexample% cp -r ~/src ~/bkup

example% ls -R ~/bkupx.c y.c z.sh

example% cp -r ~/src ~/bkupexample% ls -R ~/bkup

src x.c y.c z.sh

src:

x.c y.c z.sh

ENVIRONMENT

See environ(5) for descriptions of the following environment

LC_CTYPE, LC_MESSAGES, and NLSPATH

EXIT STATUS

The following exit values are returned:

Trang 33

arguments that begin with a -.

second will be interpreted as a filename

Trang 34

Commands which are to be executed only once may be submittedusing the at(1) command.

new or changed files at regularly scheduled intervals

things) as a lock file to prevent the execution of more thanone instance of cron

option was specified when the job was submitted)

Setting cron Defaults

log is a user configurable option since cron usually createshuge log files

Trang 35

Example /etc/default/cron file:

CRONLOG=YESPATH=/usr/bin:/usr/ucb:

continue to use /usr/sbin:/usr/bin

/etc/cron.d/logchecker is a script that checks to see if the

file is moved to /var/cron/olog

FILES

log file exceeds system ulimit

batch, and cron

/var/cron/log and (possibly) /var/cron/olog

Trang 36

Initialization and Termination

that starts with `-', as when started by login(1), the shellruns as a login shell

If the shell is a login shell, this is the sequence of

see below "Command Execution" and exec(2).)

checks as those for cshrc are applied to this file

Interactive Operation

After startup processing is complete, an interactive C shell

Trang 37

command input is read and broken into words This sequence

each command in the current line

Noninteractive Operation

When running noninteractively, the shell does not prompt for

or interpret commands from a file, also known as a script

OPTIONS

shell options This allows the passing of OPTIONS

this option is present

the argument-list variable, and passed directly tocsh

a nonzero exit status

.login file (if a login shell) upon startup

even if the standard input does not appear to be aterminal (character-special device)

for syntax errors

(backslash) can be used to escape each newline for

input lines

Trang 38

-v Verbose Set the verbose predefined variable;

(but before other substitutions) and before tion

all substitutions and just before execution

script

USAGE

Filename Completion

When enabled by setting the variable filec, an interactive C

character on the terminal input line, the shell fills in theremaining characters of a matching filename from the workingdirectory

If a partial filename is followed by the EOF character

command line typed in so far

file in the working directory

ignored fignore does not affect the listing of filenames bythe EOF character

Lexical Structure

Trang 39

characters, except as noted below The characters &, |, ;,

new-line preceded by a \ is equivalent to a space character

partial word; metacharacters in such a string, including any

Sub-stitution, and Filename Substitution

\ or enclosed in matching quotes

Command Line Parsing

com-mand is redirected to the standard input of the comcom-mand that

output are redirected through the pipeline

they are executed sequentially Pipelines that are separated

failure, respectively, of the pipeline on the left

A pipeline or sequence can be enclosed within parentheses `(

pipeline or sequence

"in the background" by appending an `&'; rather than waiting

associated process IDs and prompts immediately

Trang 40

History Substitution

history list, the size of which is controlled by the history

meaning

the terminal after being expanded, but before any other stitutions take place or the command gets executed

sub-Event Designators

in the history list

by a space character, tab, newline, = or (

substitution repeats the previous command

str

!?str?

Refer to the most recent command containing str

!?str? additional

and append additional to that referenced command

!{command} additional

command

^previous_word^replacement^

This is equivalent to the history substitution:

!:s/previous_word/replacement/

To re-execute a specific previous command AND makesuch a substitution, say, re-executing command #6,

!:6s/previous_word/replacement/

Trang 41

Word Designators

command, while !!$ and !$ both refer to the last word in theprevious command Word designators include:

just one word in the event

Modifiers

following modifiers, preceded by a :

head

leav-ing the basename

s/l/r/

Substitute r for l

the tail

example, g&)

sub-stitutions

charac-ter, tab or newline

Trang 42

string matches.

either from a l or from a contextual scan string s from !?s

similarly be omitted

reference on the command line (if any)

The C shell maintains a list of aliases that you can create,

The shell checks the first word in each command to see if it

substitu-tion is called for, the arguments remain unchanged

Aliases can be nested That is, an alias definition can

in pipelines such as

more(1)

Ngày đăng: 10/12/2013, 14:16

TỪ KHÓA LIÊN QUAN