018 020




Bourne Shell Quick Reference Guide:




















Previous
Table of Contents
Next




Program Format:
Patterns in program can be associated with a statement to perform if an input line matches the pattern. The format is:



pattern { statement }


A missing pattern always matches, and a missing statement prints the current input line.

Patterns:



BEGIN
match before first input line

END
match after last input line

pattern1, pattern2, ..., patternn
match if pattern1, pattern2, or patternn match current input line

pattern1 && pattern2
match if pattern1 and pattern2 match current input line

pattern1 || pattern2
match if pattern1 or pattern2 match current input line

!pattern
match if pattern does not match current input line

/regular-expression/
match if regular-expression matches current input line

relational-expression
match if relational-expression evaluates to true


Flow Control Statements:



break
exit from a for or while loop

continue
execute next for or while loop

delete variable[expression]
delete element expression from array variable

do statement while (expression)
execute statement while expression is true

exit
skip remaining input

for (expression1; expression2; expression3) statement
execute statement while expression2 is true; loop is usually initialized with expression1 and incremented with expression3

for (variable in array) statement
execute statement, setting variable to successive elements in array

if (expression) statement1 [ else statement2 ]
execute statement1 if expression is true, otherwise execute statement2

next
skip rest of the input line

return[expression]
return value of expression

system(command)
execute command and return status

while (expression) statement
execute statement while expression is true


Input/Output Statements:



close(file)
close file

getline
set $0 to next input record; set NF, NR, FNR

getline<file
set $0 to next input from file; set NF

getline var
set var to next input record; set NR, FNR

getline variable<file
set variable to next input record from file

command | getline
pipe output of command into getline

print
print current input record

print expression
print expression; multiple expressions must be separated with a ","

print expression>file
print expression to file; multiple expressions must be separated with a ","

printf format expression
print expression according to C-like format. Multiple expressions must be separated with a ",". Output can also be appended to file using >> or piped to a command using |.

printf format expression>file
print expression to file according to C-like format. Multiple expressions must be separated with a ",". Output can also be appended to file using >> or piped to a command using |.






Previous
Table of Contents
Next













Wyszukiwarka

Podobne podstrony:
018 020
018 020
pagon 018
020 021
018 Flm
018 19
017 020
018 13 (2)
J 020 zasilacz reg 3A

więcej podobnych podstron