UNIX AWK User Manual

zhaozj2021-02-08  228

Home => UNIX Development Technology => This article

Application Technology

System principle

Development Technology

network technology

System and network security

UNIX culture

SCO Zone

Linux area

UNIX resource

Other resources

UNIX AWK User Manual (Second Edition)

Pool Dragon

The author's words: "UNIX AWK User Manual" is the work I have a few months old. When I look back, this article is really hard, because I am writing and uploading this work is too busy, there is no right The quality of the article is very good, and the heart feels that there is a love for netizens. So I quickly rewritten it, although I don't necessarily have a big change, but the quality is sure to be better, only, my Good care is good, 呶, 呶, below is my revised draft, your old friends please compare with the first edition, see if there is further progress! This rewrite still retains the original style: The text is attached to the deep, and the text has attached a lot of relevant information. The reason is to meet the needs of various users, which has been said in the first edition. This major change is on the content, adding a lot of new content, and adds an example to help readers understand the content, and the appendix has also added many new information. Of course, the reader must truly master the awk, just reading this article is not enough, and must have a step in the machine. It is worth reminding everyone that AWK has a lot of versions, and there are some differences between each version, so it is best to refer to the online help you use before using AWK. What is awk? You may be more familiar with Unix, but you may be very strange to awk, this is not surprising, it is indeed, AWK is far from the well-known manner than its excellent function. What is AWK? Unlike most of the other UNIX commands, from the name, we cannot know the function of awk: it is neither an independent English word, nor a few related words abbreviation. In fact, AWK is an abbreviation of three people, they are: AHO, (Peter) Weinberg and (Brain) kernighan. It is these three people created awk - an excellent style scan and processing tool. What is the function of awk? Similar to SED and GREP, AWK is a style scan and processing tool. But its function is great for Sed and GREP. AWK provides an extremely powerful function: it can complete all the work that GREP and SED can do, while it can also make styles, stream control, math operators, process control statements, or even built-in variables and functions. . It has a complete language that should have almost all exquisite features. In fact, AWK does have your own language: awk programming language, the three creators of awk have officially defined it as: style scan and handling language. Why use awk? Even so, you may still ask, why should I use aw? The first reason for using aw is that the text-based style scan and handling are the work we often do, and the work of AWK Some iconic databases. However, it is different from the database that it processes text files, which do not have special storage formats, and ordinary people can edit, read, understand, and handle them. Database files often have special storage formats, which make them need to process them with database handles. Since this type of process similar to the database will often encounter, we should find a simple and easy way to handle them. Unix has many tools, such as SED, GREP, SORT, and Find, AWK is among them. A very good one. The second reason to use aw is that awk is a simple tool, of course, this is relative to its powerful function. Indeed, Unix has many excellent tools, such as UNIX Natural Development Tools C language and its continuation C is very excellent. But relative to them, AWK has more convenient and simple to complete the same function.

This is the first because AWK provides a solution to a variety of needs: from the AWK command to solve the simple problem to the complex and more and intrinsic awk programming language, the advantage is that you can solve the original use of complex methods. Simple problem. For example, you can use a command line to solve a simple problem, and C can't, even if a simple program, the C language must be written, compiled. Second, the awk itself explains the execution, which makes the AWK program do not have to compile the process, and this also makes it possible to match the shell script program. Finally, the AWK itself is simpler, although AWK absorbs a lot of excellent ingredients in C language, familiar with C language has a lot of help, but awk itself does not need to use C language - a powerful but need A large number of time learning can master the development tools of their skills. The third reason to use aw is that awk is an easy tool. Unlike C and C languages, AWK has only one file (/ bin / awk), and almost every version of Unix provides a version of AWK, you don't have to worry about how to get awk. However, the C language is not the case, although the C language is UNIX natural development tool, but this development tool is released separately. In other words, you must pay for your UNIX version of C language development tool (especially except for D version ), Get and install it, then you can use it. Based on the above reasons, we have the powerful function of AWK. We have reason to say that if you want to handle the work related to text style scanning, the awk should be your first choice. There is a general principle that can be followed here: if you have difficult words with ordinary shell tools or shell script, try awk, if the awk does not solve the problem, use the C language, if the C language still fails, then move to C . AWK's call mode has been said before, AWK provides different solutions to a variety of needs, they are: 1. AWK command line, you can use awk like using the ordinary unix command, you can also use awk in the command line Programming language, although AWK supports multi-line entry, but enters long command lines and ensures that it is correct, this method is generally only used to solve simple problems. Of course, you can also quote the awk command line or even the AWK program script in the Shell Script program. Second, call the AWK program using the -f option. AWK allows a paragraph AWK program to be written to a text file and then call and execute this program in the AWK command line. Specific methods We will tell them in the back AWK grammar. Third, using the command interpreter to call the AWK program: Use the unix support command interpreter function, we can write a AWK program to the text file, then add: #! / Bin / awk -f and give This text file is permutable. After doing this, you can call and execute this AWK program in the command line. $ awk script text name to handle file AWK Syntax: Like other UNIX commands, awk has its own grammar: awk [-f re] [parameter ...] ['prog'] [-f progfile] [in_file .. .] Parameter Description: -f RE: Allows AWK to change its field separator. Parameter: This parameter assists for different variables. 'prog': AWK's program segment. This segment must be enclosed in single-extension: 'and' to prevent it from the shell.

The standard form of this program segment is: 'pattern {action}' wherein the pattern parameter can be any of the EGREP regular expression, which can use syntax / RE / plus some style matching skills. Similar to SED, you can also use "," separate two patterns to select a range. With regard to the details of the match, you can refer to Appendix, if you still don't understand, find this UNIX book learning GREP and SED (I have a matching technology when learning ED). The Action parameter is always surrounded by braces, which consists of a system AWK statement, and the statements are separated by ";". AWK explains them and performs its operations on the records that match the pattern given by Pattern. Similar to Shell, you can also use "#" as an comment, which makes "#" to the end of the row, and it will be ignored when interpreting is executed. You can omit one of Pattern and Action, but it cannot be omitted simultaneously. When Pattern is omitted, there is no style matching, indicating that all rows (records) are executed, omit the Action, and the default operation is issued - displayed on the standard output . -f progfile: Allows AWK to call and perform ProgFile specified with program files. PROGFILE is a text file that he must conform to the AWK syntax. In_File: AWK input file, AWK allows multiple input files to be processed. It is worth noting that AWK does not modify the input file. If you do not specify an input file, AWK will accept the standard input and display the result on the standard output. AWK supports input and output redirection. AWK record, fields and built-in variables: The Work of the AWK processing is the same as the database's processing method, and one of the same is the processing of the AWK supports the processing of records and fields, where the processing is GREP and Sed cannot be implemented, this is also one of the reasons for AWK better than the two. In AWK, the line in the text file is always treated as a record in the default, and some of the line is a field in the record. To operate these different fields, AWK borrows the shell method, sequentially represents the different fields in the row (record) with $ 1, $ 2, $ 3 ... in such a way. Specially, AWK expresses the entire row with $ 0. Different fields are separated by characters called separators. The default separator is spaced. The AWK allows this separator to change this separator in the form of -f RE in the command line. In fact, AWK remembers this separator with a built-in variable FS. There are several such built-in variables in AWK, for example, record the separator variable RS, the current work record number NR, etc., the table later, lists all built-in variables. These built-in variables can be referenced or modified in the AWK program, for example, you can use the NR variable to specify the operating range in the mode match, or by modifying the record separator RS to make a special character rather than a resilive separator. Example: Display text file Myfile Seventh line in Chapter VI in Characters, third fields, and seventh fields: awk -f% 'NR == 7, NR == 15 {PrintF $ 1 $ 3 $ 7} 'awk's built-in function awk is a reason to become an excellent programming language is that it absorbs many of the advantages of some excellent programming languages ​​(eg C) languages.

One of these advantages is the use of built-in functions, and the awk defines and supports a series of built-in functions. Due to the use of these functions, the features provided by AWK are more complete and powerful, for example, AWK uses a series of string to process built-in Function (these functions look like the string processing function of the C language, the functions in the use of the C language are different from those of these built-in functions, making the AWK processing string more powerful. The built-in functions provided in the appendix in this article have a general AWK, which may have some access to your AWK version, so before using it, it is best to refer to online help in your system. As an example of a built-in function, we will introduce the Printf function of awk here, which makes the AWK match the output of the C language. In fact, there are many reference forms from the AWK to borrow from the C language. If you are familiar with the C language, you may remember the Printf function, which is the powerful format output function that has taken us many of our convenience. Fortunately, we reunite with it in AWK. Printf in AWK is almost the same as the C language. If you are familiar with C language, you can use the Printf in the AWK in the C language mode. So here, we only give an example. If you are not familiar, please find an entry into the C language. Example: Display file number and third field in MyFile: $ awk '{Printf "% 03D% S / N", NR, $ 1}' myfile In command line Using awk in order, we should explain the contents of the AWK program design But before explaining, we will use some examples to review the previous knowledge, which are used in the command line, where we can know how convenient to use AWK in the command line. On the one hand, the reason for this is the following, on the other hand, the other hand introduces some methods to solve the simple problem, we don't have to use a complex method to solve simple problems --- Since AWK provides simpler Method's words. Example: Displays all rows of text file MyDoC matching (containing) strings "sun". $ awk '/ sun / {print}' MyDoc Since the entire record (full line) is the default action of awk, the Action item can be omitted. $ awk '/ sun /' mydoc example: The following is a more complex matching example: $ awk '/ [ss] un /, / [mm] OON / {print}' myfile It will display the first matching Sun or Sun's row with the first row between the rows of Moon or Moon and displays them on the standard output. Example: The following example shows the use of built-in variables and built-in functions Length (): $ awk 'length ($ 0)> 80 {print nr}' MyFile This command line will display all the line numbers in all 80 characters in the text MyFile, Here, with $ 0 to represent the entire record (line), the built-in variable NR does not use the flag '$'. Example: As a more practical example, we assume that you want to check the users in UNIX, the method is to examine the Passwd file under / etc, check whether the Passwd field (second field) is "*", if not To "*", the user does not set a password, showing these usernames (first fields).

We can use the following statement: #awk -f: '$ 2 == "" {Printf ("% s no password! / N", $ 1' / etc / passwd In this example, the field separator of the Passwd file is " : The function of providing variables is the present request of the programming language, and the programming language that does not provide variables I have never seen .Awk provides two variables, one is the built-in variable built into the AWK, which we have already said, It is necessary to focusing, different from the other variables mentioned later, reference to the built-in variable in the AWK program does not need to use the flag "$" (recall the use of the previous NR). Another Variables are custom variables. The wk allows users to define and call their own variables in the AWK program statement. Of course, this variable cannot be the same as the built-in variable and other AWK reserves, reference to custom variables in AWK must be added in front of it. The value "$". Unlike the C language, the variable does not need to initialize the variables, and AWK determines its specific data type according to its form and context appearing in the AWK. When the variable type is uncertain, AWK Default is a string type. There is a tip here: if you want your awk program to know the clear type of the variable you use, you should assign a initial value in the program. In the following instance, we will Use this skill. Computing and judgment: As one of the characteristics of programming language, AWK supports multiple operations, and these operations are provided with C language: if , -, *, /, %, Etc., at the same time, awk also supports the function similar to , -, =, - =, = , = - from the C language, which has a great It is convenient. As an extension of the calculation function, AWK also provides a series of built-in computing functions (such as log, sqr, cos, sin, etc.) and some functions for operating (calculating) the string (calculation). Such as Length, Substr, etc.) This function is greatly improved by AWK's computing function. As part of the conditional transfer instruction, the relationship judgment is the function of each programming language, and AWK is no exception. AWK is allowed Make a variety of tests, such as common == (equal),! = (Not equal),> (greater than), <(less),> = (greater than or equal),> = (less than or equal), etc., Pattern matching, also provides ~ (match) and! ~ (Not match) judgment. As an expansion of the test, AWK also supports logical operators:! (Non), && (with), || Or) and parentheses () multiple judgments, this Greatly enhances the function of awk. The appendix of this article lists the operations, judgments, and operators allowed by AWK. The AWK process control flow control statement is unable to have some programming languages. Any good language has some statements that perform process control.

The complete process control statement provided by AWK is similar to the C language, which makes us great convenience. 1, Begin and End: Two special expressions, begin, and end in awk, both of which can be used in Pattern (refer to the AWK syntax for the previous AWK syntax), providing Begin and End's role to give the program to the initial state and Execute some sweeping work after the end of the program. Any operation listed after BeGin (in {}) will execute before the AWK starts scan input, and the operation listed after the end will be executed after the input of the scanner. Therefore, begin is usually used to display variables and preset (initialized) variables, using END to output the final result. Example: The sales amount in the Tumber Sales File XS (assuming sales amount is recorded in the third field): $ awk> 'begin {fs = ":"; print "Statistical sales amount"; Total = 0}> {Print $ 3; Total = Total $ 3;}> end {printf "Sales total total:%. 2f", total} 'sx (Note:> is the second prompt provided by the shell, if you want to wrap in the shell program awk statement and the AWK language, It is necessary to add inversion on the tail of the row /) here, BeGin presets internal variable FS (field separator) and custom variable Total, which shows the output line before scanning. End prints a total assembly after the scan is completed. 2, the process control statement AWK provides a complete flow control statement, which is similar to the C language. Let's explain: 2.1, if ... ELSE statement: Format: if (expression) statement 1ELSE statement 2 "Statement 1" in the format can be multiple statements, if you are easy to read, you can read it. You'd better enclose multiple statements to {}. AWK branching structure allows nested, format: if (Expression 1) {if (Expression 2) Statement 1ELSE Statement 2} Statement 3ELSE {IF (Expression 3) Statement 4ELSE Statement 5} Statement 6 Of course, actual operation You may not use such a complex branch structure, here is just to give its styles. 2.2, while statement format is: while (expression) statement 2.3, do-while statement format is: do {语句} why (condition judgment statement) 2.4, for statement format is: for (initial expression; termination conditions; step size Expression) {Statement} In the WHILE, DO-While, and FOR statements in AWK, it is allowed to use the Break, Continue statement to control process trends, which also allows the statement such as EXIT to exit. BREAK interrupts the currently executing loop and jumps to the next statement outside the loop. Continue jumps from the current location to the beginning of the cycle. There are two cases for execution of Exit: When the exit statement is not in End, the exit command in any operation is characterized by the file end, all modes, or operation execution will stop, and the operation in the End mode is executed. EXIT that appears in End will cause the program to terminate. Example: For custom functions in awk, the user's own function is the function of almost every high-level language. AWK is no exception, but the original AWK does not provide functions, only in Nawk or Newcom. The function can be added in the version. The use of functions contains two parts: the definition of the function is called with the function. The function definition includes a temporary call to the code (function itself) to be executed and passed from the main program code to the function. The definition method of the AWK function is as follows: Function function name (parameter table) {Function body} Allows FUNCTION to omit into FUNC in Gawk, but other versions of AWK is not allowed.

The function name must be a legitimate flag, and the parameter can not be provided in the parameter table (but a pair of parentheses after the function name is still indispensable) or one or more parameters can also be provided. Similar to the C language, the parameters of AWK are also passed through a value. The transfer function in the awk is relatively simple, and its method is similar to the C language, but AWK is more flexible than C language, it does not perform parameter validity check. In other words, when you call the function, you can list more or less parameters than the function expected (function definition), which will be ignored by AWK, instead of the parameters, and the AWK set them by default. A value of 0 or empty strings, which is set, depending on the way of use of the parameters. There are two ways to return: implicit return and explicit returns. When the awk is executed to the end of the function, it automatically returns to the calling program, which is implicitly returned. If you need to exit the function before the end, you can use the return statement to exit in advance. The method is to use the statement in the function such as RETURN Return value format. Example: The following example demonstrates the use of functions. In this example, a function named Print_Header is defined. The function calls two parameters filename and PAGENUM, the filename parameter passed the file name currently used, and the PAGENUM parameter is the page number of the current page. The function of this function is to print (display) the file name of the current file, and the page number of the current page. After completing this feature, this function will return to the page number of the next page. NAWK> 'Begin {Pageno = 1; file = filename> Pageno = Print_Header (file, Pageno); # call function print_header> Printf ("current page number:% D / N", Pageno);>}> # definition Function Print_Header> Function Print_Header (FileName, Pagenum) {> PRINTF ("% S% D / N", filename, Pagenum);> Pagenum ; Return Pagenum;>}>} 'MyFile Execute this program will appear: MyFile 1 The current page number is: 2AWK Advanced Input Output 1. Read Next Record: AWK's next statement causes the AWK to read the next record and complete the pattern match, then perform the appropriate operation. It usually performs the code in the operation with a matching mode. NEXT causes any additional matching mode of this record to be ignored. 2. Simply read a record of the getLine statement of a WK is used to simply read a record. If the user has a data record similar to two physical records, GetLine will be especially useful. It completes the separation of the general field (set field variable $ 0 FNR NF NR). If success, return 1. If it fails, it returns 0 (reaching the file end). If you need to simply read a file, you can write the following code: Example: Example Getline use {while (getLine == 1) {# process the inputted field}} can also make GetLine save input data in a field, and Not processed by using getline variable. When this method is used, NF is set to 0, the FNR, and NR are added. Users can also enter data from a given file in a GetLine <"filename" mode instead of entering data from the command line. At this point, GetLine will complete the general field separation (set field variables $ 0 and NF).

If the file does not exist, return -1, success, return 1, return 0 means failure. The user can read data from a given file into a variable, or use stdin (standard input device) or a variable containing this file name instead of FileName. It is worth noting that the FNR and NR are not modified when using this way. Another way to use the getLine statement is to accept input from the UNIX command, such as the following example: Example: Example Accepting the input from UNIX command {While ("" "" "" | {# Process Each Line from the who commman}} Of course, you can also use the following form: "Command" | getLine Variable3. Close File: AWK Allows to close an input or output file in the program, the method is to use the AWK's Close statement. Close ("filename") filename can be a file that getLine is open (or stdin, a variable containing the file name or the exact command used by getLine). Or an output file (which can be stdout, a variable containing the file name or the exact command to use the pipeline). 4. Output to a file: AWK is allowed to output the result to a file: Printf ("Hello Word! / N")> "DataFile" or Printf ("Hello Word! / N") >> "DataFile" 5. Output to a command AWK Allow to output the result to a command: Printf ("Hello Word! / N") | "Sort-T ','" AWK and Shell Script Mixed Programming Because AWK can act as a shell The command is used, so the AWK can be well integrated with the shell batch program, which provides a possibility that the AWK and Shell programs are provided. The key to achieving the mixed program is a dialog between awk and shell script. In other words, the information exchange between awk and shell script: awk Gets the required information from the shell script (usually the value of the variable), executing in the AWK The shell command line, the shell script sends the results executed by the command to the AWK process and the SHELL Script read the execution result of the AWK. 1.awk Read the shell Script program Variable In AWK we can read the variables in the Sell Script program through the "'$ Variable Name'". Example: In the example below, we will read the variable Name in the Sell Scrpit program, which is stored in the text MyFile, and the AWK will print out. $ CAT WRITENAME: # @ (#) # ... name = "Zhang 3" nawk 'begin {name = "' name '"; / printf ("/ t% s / t writer% S / N", FileName , Name ");} / {...} end {...} 'myfile ... 2. Send the execution result of the shell command to the AWK processing as a method of information transmission, we can put a shell command The result is passed to the AWK processing by a pipeline (|): Example: Example AWK Processing the results of the shell command $ WHO -U | awk '{printf ("% s is executing% S / N", $ 2, $ 1)}' The command will print out the program name that the registered terminal is being executed.

3. SHELL SCRIPT Program Read AWK Execution Result In order to implement the result of the shell script program to read the result of the AWK execution, we can take some special methods, such as we can use the variable name = `awk statement to put the result of AWK execution A Shell Script variable. Of course, you can also pass the AWK execution to the Shell Script program processing by means of a pipeline. Example: As one of the mechanisms of transferring messages, UNIX provides a command Wall that is sent to all of the user transfer messages (meaning Write to ALL writes to all users), which allows the message to be sent to the user (terminal) in all works. To do this, we can simulate this program through a shell batch program Wall.Shell (in fact, the old version Wall is a shell batch program: $ cat wall.shell :# @ (#) Wall.Shell: Send a message to each registered terminal #cat> / tmp / $$ # User Enter a message WHO -U | awk '{print $ 2}' | While Read TTYDOCAT / TMP / $$> $ TTYDONE in this program, awk Accept the execution result of the WHO -U command, the command prints out all the registered terminals, where the second field is the device name of the registered terminal, so use the awk command to precipitate the device name, then use the While Read TTY statement to read Out of these files named variable (Shell Script Variable) TTY, as the end address of the information transfer. 4. Execute the shell command line in the AWK ---- Embedded function system () system () is a non-figures or digital type The function of the function is that the function of this function is to process a string that is passed to it. System's processing is handled as a command, which means it as a command line. This makes the user The AWK program needs to be flexibly executed. Example: The following program will use the System embedded function to print the user-prepared report file, this file is stored in a file named myreport.txt. For the sake of simplicity, we only Listrate its end section: ... End {Close ("MyReport.txt"); System ("lp myreport.txt");} In this example, we first use the close statement to close the file myreport.txt file, Then use the System embedding function to transfer myReport.txt into the printer print. Write here, I have to say goodbye to my friends, I really said that these content is still AWK's initial knowledge, the computer is always the science, AWK is also No exception, this article can only paveled a small opening in your long way, the remaining road has to go to you. Honestly, if this article can really give you the way to you It is convenient to come, then I have a content! If you have any questions about this article, please e-mail to: chizlong@yeah.net or go to the homepage http://chizling.yeah.net message. Appendix: 1.Awk Conventional Expression Metacity / Call Code Sequence ^ Start Matching $ The end of the string starts matching. Match any of [ABC] and [] in [ABC] and [] match [ABC] with any single string match [A-CA-C] ] And AC and Characters in the A-C range (in alphabet sequence) [^ ABC] and any character other than all characters in [] match DESK | Chair with any of DESK and CHAIR [ABC] [DEF] associated. Match with any of A, B, and C, and thereafter, it is necessary to follow any of the characters in D, E, and F.

* Compared with any one of the A, B or C, a character matching any one of A, B or C occurs once or multiple characters in any one or multiple times? Matching a null string or A, b or c (Blue | Black) Berry combines conventional expressions, matching Blueberry or BlackBerry 2.awk arithmetic operator operator -------- ---------- x ^ yx YTi-powered x ** y with the upper x% y to calculate the remainder of X / Y (SD) X YX plus YX-Y X reduction YX * YX multiply YX / YX except yy negative y (Y's switch symbol); also known as a decrease yy plus 1 after using Y (front plus) Y use Y value plus 1 (suffix plus) - YY minus 1 after 1 after 1 (before Setting) Y - After using Y minus 1 (Refix) x = Y assigns the value of Y to XX Y Y to assign XX- = Y to assure XX * = Y The value of x * y assumes XX / = Y to assign XX% = Y to assure x% y's value to X

X ^ = y assumes the value of x ^ y to X

X ** = y assigns the value of x ** y to X

3. AWK Allowed Test:

Operator meaning

X == y x equal to Y

X! = y x does not equal Y

x> y x is greater than y

X> = y x is greater than or equal to Y

x

X <= y x less than or equal to Y?

X ~ RE X matches the regular expression RE?

X! ~ RE X does not match the regular expression RE?

4.Awk's operator (arranged as a priority)

=, =, - =, * =, / =,% =

||

&&&&

>> = <<= ==! = ~! ~

XY (string of strings, 'X''n' "becomes" xy ")

-

* /%

-

5.awk built-in variable (predefined variable)

Note: The V item represents the first tool (below) of the first support variable: a = awk, n = nawk, p = pOSIX awk, g = Gawk

V variable meaning default

-------------------------------------------------- --------

N argc command line parameters number

G argind currently processed Argv flag

N argv command line parameter array

G CONVFMT digital conversion format% .6g

P Environ UNIX environment variable

N Errno UNIX system error message

GfieldWidths Enter a blank separation string of field width

A FileName The name of the current input file

P fnr current record number

A FS input field separator space

G ignorecase control sensitive 0 (case sensitive)

A nf current record in the current record

A NR has read the number of records

A OFMT digital output format .6g

A OFS output field separator space

A new line of record separator output by A ORS output

A RS entered recorded in his jam

N RSTART is the string of the string of matching functions

N rlength is matched by a string length

N subsep subscript "/ 034"

6.awk's built-in function

V function use or return value

------------------------------------------------

N GSUB (REG, STRING, TARGET) replaces String in Target each time regular expression REG matches

N index (Search, String) Returns the position of the SEARCH string in STRING String String string string String characters

N Match (string, reg) Returns location in string, regular expression REG matches

N printf (Format, Variable) Format Output, pressing the format Variable by Format.

N split (string, store, delim) is decomposed as a Store array element based on dividing character Delim.

N sprintf (Format, variable) Returns a data containing Format-based formatted data, and variables is data to be placed in strings.

G struntime (format, timestamp) Returns a Format-based date or time string, TimeStmp is the time returned by the system () function

N sub (reg, string, target) for the first time when a regular expression REG matches, replacing the string in the Target string

A SUBSTR (String, Position, LEN) Returns a substring that starts LEN characters in POSITION

P Totower (String) Returns the corresponding lowercase characters in the string

P TouPper (String) Returns the corresponding uppercase characters in the string

The remainder of A Atan (X, Y) X (radians)

N cos (x) x cosine (radians)

X Power A Exp (x) E

A INT (X) X integer part

A log (x) x natural logarithmic value

Random number between n rand () 0-1

N sin (x) x sine (curvature)

A square root of A SQRT (X) X

A SRAND (X) initializes the random number generator. If you ignore X, use system ()

G system () returns the time since January 1, 1970 (calculated by second)

Reference

1. "Proficient Unix" ("Understanding Unix" [US] Stan Kelly-bootle Li Yongfeng et al, Emotion Electronic Industry Press)

2, "UNIX User Guide" (2nd Edition) (Second Edition) Steve Moritsugu, etc. Original Zhang Zhijun, Han Ke, Yuan Xiaoling and other translations, released

3, UNIX online manual: SCO OPENSREVER version 5.05.

4, thanks to the unknown network resource provider, because of your hard work, the Internet is so wonderful!

Pool Dragon Production / Maintenance

Copyright by Chizlong 2000 / 02-2000 / 12, China