Category : Miscellaneous Language Source Code
Archive   : QTAWKD42.ZIP
Filename : QTAWK.MAN
Output of file : QTAWK.MAN contained in archive : QTAWKD42.ZIP
QTAwk 4.20 QTAwk
QTAwk Version 4.20 10/10/90 QTAwk
Name
QTAwk - Pattern Scanning and Processing Language
QTAwk - 4.20 10-10-90
Synopsis
QTAwk [-f file | -ffile | "program"] [-Fstr] [var=text | file | -
| -- ] ...
DESCRIPTION
QTAwk scans each input file for lines that match any of a set of
patterns specified in the program. With each pattern in the
program there can be an associated action that will be performed
when a line of a file matches the pattern.
The QTAwk program may be specified as a file with the -f option
as:
-ffilename.ext
-f filename.ext
in which case the QTAwk program is read from the named file. If
the file does not exist then an error message will be printed.
Multiple 'f' options specifying program files may be used. Each
program file is read in the order given and the total program
consists of all files read.
The QTAwk program may also be specified as a single argument as:
"{ for (i in ARGV) printf ("%d: %s\n", i, ARGV[i]); }"
If the -f option is selected the full path/name/extension must
be specified.
Files are read in order, the file name '-' means standard input.
Each line is matched against the pattern portion of every
pattern/action statement. The associated action is performed for
each matched pattern.
QTAwk - 1 - QTAwk
QTAwk 4.20 QTAwk
A command line argument of "--" will stop the scan for more
options.
If a file name has the form variable=value or "variable =
value", the variable named is set to the value specified. Program
variables may be changed before a file is read. The assignment
takes place when the argument would be treated as the next file
to read. "variable" must be a variable name defined in the QTAwk
program.
QTAwk "{ print code, NR, $0 }" code=10 file1 code=75 file2
No assignment will happen before a BEGIN block, however an
assignment after the last file will occur before any END block
unless an exit was performed.
If no files are specified the input is read from standard input.
An input line is made up of fields separated by the field
separator FS. The fields are denoted by $1, $2, ..., $NF. NF
equals the number of fields the input record has been split to
make. $0 denotes the entire line:
$0 = "now is the time"
$1 = "now"
$2 = "is"
$3 = "the"
$4 = "time"
with the default FS = [\s\t], white space. If the field
separator is set to comma, ',' with "-F," on the command line or
"FS=','" on the command line, or in the program, then the fields
might be:
$0 = "a, b,c,, ,"
$1 = "a"
$2 = " b"
$3 = "c"
$4 = ""
$5 = " "
$6 = ""
A pattern-action statement has the form:
QTAwk - 2 - QTAwk
QTAwk 4.20 QTAwk
pattern { action }
A missing { action } has the same effect as { print $0; }, a
missing pattern always matches.
A pattern is a test that is performed on each input line. If the
pattern matches the input line then the corresponding action is
performed.
Patterns come in several forms:
Form Example Meaning
BEGIN BEGIN {N=1;} initialize N before input is read
INITIAL INITIAL {G=0;) initialize G before input from
each file
NOMATCH NOMATCH (G++;} increment G for each line not
matched
FINAL FINAL {print G;} print G after each file
END END {print NR} print NR after all input is read
function function x(y) define a function called x
text match /stop/ line contains the string "stop"
expression $1 == 3 first field is the number 3
compound /x/ && NF > 2 more that two fields and
contain "x"
range FNR==10,FNR==20 records ten through twenty
inclusive
BEGIN, INITIAL, NOMATCH, FINAL and END patterns are special
patterns that match respectively: before any files are opened,
after opening each file, when a line fails all patterns, after
reading the last line in each file and after all files have been
closed. There may be multiple occurances of these patterns and
the associated actions are executed in the order that they occur.
If there is only a series of BEGIN blocks in the QTAwk program
and no other pattern/action blocks except function declarations,
they are executed before reading from the standard input. If only
END blocks are defined then all the files are read and NR will be
set to the number of records in all the files.
BEGIN { page = 5 }
A function pattern is never matched and serves to declare a
user defined function.
QTAwk - 3 - QTAwk
QTAwk 4.20 QTAwk
function show(a) {local i; for (i in a) print a[i];}
A user defined function may have a variable number of arguments
defined following the C convention:
function max(...) {
local i, maxa = vargv[1];
for ( i in vargv ) if ( vargv[i] > maxa ) maxa = vargv[i];
return maxa;
}
The variable arguments are accessed through the built-in
variables vargc == the number of variable arguments passed, and
vargv == an array with element indices 1 through vargc, each
element is an argument passed.
A regular expression by itself is matched against the input
record, $0. That is "/abc/" is equivalent to "$0 ~~ /abc/".
Any expression will match if it evaluates to a non-zero numeric
or a non-null string. Also any logical combination of expressions
and regular expressions may be used as a pattern.
FILENAME != oldname && FILENAME != "skip"
The last special pattern is two expressions separated by a
comma. This pattern specifies a range of records that match the
pattern. The pattern starts to match when the first pattern
matches and stops matching when the second pattern matches. If
they both match on the same input record then only that record
will match the pattern.
/AUTHOR/,/NOTES/
An action is a sequence of statements that are performed when a
pattern matches.
A statement can be one of the following:
# simple statement
STATEMENT
# compound statement
{ STATEMENT; STATEMENT; STATEMENT; STATEMENT; ... }
# simple expression
QTAwk - 4 - QTAwk
QTAwk 4.20 QTAwk
EXPRESSION
# expression list - expressions separated
# by the sequence operator
EXPRESSION, EXPRESSION, EXPRESSION, ...
print EXPRESSION_LIST;
print( EXPRESSION_LIST );
printf FORMAT ;
printf FORMAT ,EXPRESSION_LIST ;
printf(FORMAT );
printf(FORMAT ,EXPRESSION_LIST );
fprint(filename,EXPRESSION_LIST);
fprintf(filename,FORMAT );
fprintf(filename,FORMAT ,EXPRESSION_LIST );
getline( );
getline( variable );
fgetline(filename);
fgetline(filename ,variable );
if ( EXPRESSION_LIST ) STATEMENT
if ( EXPRESSION_LIST ) STATEMENT else STATEMENT
for ( VARIABLE in ARRAY ) STATEMENT
for ( EXPRESSION_1 ; EXPRESSION_2 ; EXPRESSION_3 ) STATEMENT
while ( EXPRESSION ) STATEMENT
do STATEMENT while ( EXPRESSION );
switch ( EXPRESSION ) {
case EXPRESSION_1: STATEMENT
case EXPRESSION_2: STATEMENT
default: STATEMENT
}
break;
continue;
cycle;
QTAwk - 5 - QTAwk
QTAwk 4.20 QTAwk
delete variable[i];
deletea variable;
endfile;
exit ;
exit EXPRESSION_LIST ;
local variable_list;
local variable_list = value;
next;
return ;
return EXPRESSION ;
A Compound Statement is a list of statements separated by
semicolons and enclosed within braces, "{}". White space is
ignored beyond delimiting tokens. Thus, statements may be split
across lines where, or as necessary, for readability:
{
print "value:", i,
"number:", j;
i = i + $3; j++;
}
An EXPRESSION_LIST is any number of valid expressions separated
by the sequence operator, the comma ','.
Expressions take on string or numeric values depending on the
operators. There is only one string operator, concatenation,
indicated by adjacent expressions or the symbol ï (extended ASCII
hexadecimal 0xef, decimal 239). The following are the operators
in order of increasing precedence:
Operation Operator Example Meaning
sequence , x=2,y=3; assign 2 to x then
assign 3 to y
assignment = x = 2 two is assigned to x
assignment ^= *= /= x += 2
%= += -=
&= |= @=
QTAwk - 6 - QTAwk
QTAwk 4.20 QTAwk
<<= >>= ï= two is added to x
conditional ? : x ? y : z if x then y else z
logical OR || x || y if (x) TRUE
or (y) TRUE
then TRUE else FALSE
logical AND && x && y if (x) TRUE
and (y) TRUE
then TRUE else FALSE
bit-wise XOR @ x @ y x XOR y
bit-wise OR | x | y x OR y
bit-wise AND & x & y x AND y
array
membership in x in y if ( y[x] exists )
TRUE
else FALSE
matching ~~ !~ $1 ~~ /x/ if ($1 contains x)
TRUE
else FALSE
equality == != x == y if (x equals y)
TRUE
else FALSE
relational < <= >= > x < y if (x less than y)
TRUE
<= >= < else FALSE
bit shift << >> x << 2 shift value of x
2 bits left
concatenation "x" "y" a new string "xy"
concatenation ï "x" ï "y" a new string "xy"
add, subtract + - x + y sum of x and y
mul, div, mod * / % x * y product of x and y
exponentiation ^ x^y x to the yth power
unary
plus minus + - -x negative of x
one's complement
~ ~x one's complement
of x
inc/dec ++ -- x++ x then add 1 to x
logical not ! !x if (x is 0 or null)
TRUE
else FALSE
tag $$ $$0 the string matched
in the pattern
field $ $3 the 3rd field
subscripting [] x[2] element 2 of x
QTAwk - 7 - QTAwk
QTAwk 4.20 QTAwk
grouping () ($1)++ increment the
1st field
Variables may be scalars, array elements (denoted x[i]) or
fields (denoted $expression). Variable names begin with a letter
or underscore and may contain any number of letters, digits, or
underscores.
Array subscripts may be any integer or string. Multi-dimensional
arrays are supported by QTAwk and accessed in the C manner:
x[2][1]
Variables are initialized to both zero and the null string.
Fields and the command line arguments will be both string and
numeric if they can be completely represented as numbers. The
range for numbers is 1E-306 ... 1E306.
for numeric operations, if both operands are integers, the
result is an integer. Thus, 3 / 2 is 1, but 3.0 / 2 is 1.5.
Comparison will be numeric if both operands are numeric
otherwise a string comparison will be made. Operands will be
coerced to strings if necessary. Uninitialized variables will
compare as numeric if the other operand is numeric or
uninitialized. Eg. 2 > "10" and 2 < 10.
There are a number of built in variables they are:
Variable Meaning Default
_arg_chk flag to check number
of arguments 0
ARGC number of command
line arguments -
ARGI array of command
line arguments -
ARGV subscript value for
next command line argument -
CYCLE_COUNT Count of cycle statement -
DEGREES degree flag 0
ENVIRON array of environment strings -
FALSE false 0
FILENAME name of current input file -
FNR record number in current file -
FS controls the input
field separator /[\t-\r\s]+/
QTAwk - 8 - QTAwk
QTAwk 4.20 QTAwk
LONGEST_EXP Longest Expression 1
MAX_CYCLE Max count of cycle statement 100
NF number of fields in current
record -
NG expression count -
NR number of records read
so far -
OFMT output format for records "%.6g"
OFS output field separator " "
ORS output record separator "\n"
RETAIN_FS Flag to retain
Field Separator 0
RS controls input
record separator "\n"
TRACE Flag to Trace Statements 0
TRANS_FROM String Translation
---> "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
TRANS_TO String Translation
---> "abcdefghijklmnopqrstuvwxyz"
TRUE true 1
CLENGTH length of string matched
in case statement -
CSTART start of string match in
case statement -
MLENGTH length of string matched
in pattern match -
MSTART start of string match in
pattern match -
RLENGTH length of string matched
by match function -
RSTART start of string match by
match function -
vargc Variable Argument count -
vargv Variable Argument array -
ARGC and ARGV are the count and an array of the values of the
command line arguments. ARGI is the index value for the next
command line argument to be processed. ARGV[0] is the full
path/name of QTAwk.exe, and the rest are all the command line
arguments except any "-F", "-f" or "--" options.
The field separator may set to a single character or a string.
If a string, it is interpreted as a regular expression and
converted to internal form at the time of assignment. A single
space has a special meaning and is changed to /[\t-\r\s]+/. A
QTAwk - 9 - QTAwk
QTAwk 4.20 QTAwk
BEGIN action may be used to set the separator or it may be set by
using the -F command line option or as a command line variable.
# sets FS to a single comma
BEGIN { FS = ",";}
# sets FS to a single space
"-F/[ ]/"
# sets FS to a single space
"FS=/[ ]/"
The record separator, RS, may be a single character or string.
If a string, then it interpreted as a regular expression and
converted to internal form at the time of assignment. Any string
matching the regular expression, becomes a record separator. The
null string, RS = "", will set RS == /\n\n/, i.e., consecutive
newlines delimit records.
There are a number of built in functions:
Function Value returned
acos(x) arc-cosine of x
asin(x) arc-sine of x
atan2(x,y) arctangent of x/y in the range
-ã to ã
center(s,w) string s centered
center(s,w,c) string s centered
copies(s,n) n copies of s
cos(x) cosine of x x in rad./deg.
cosh(x) hyperbolic cosine of x
deletec(s,p,n) deletec n characters at p
e_type(exp) expression type in range
0 to 5
execute(s) value of expression in s execute string
execute(s,se) value of expression in s execute string
execute(s,se,rf) value of expression in s execute string
execute(a) value of expression in s execute array
execute(a,se) value of expression in s execute array
execute(a,se,rf) value of expression in s execute array
exp(x) exponentiation of x (e ^ x)
fract(x) fractional portion of x
gsub(r,s) number of substitutions substitute s for
all r in $0
gsub(r,s,t) number of substitutions substitute s for
all r in t
index(s,t) position of t in s 0 if not in s
QTAwk - 10 - QTAwk
QTAwk 4.20 QTAwk
insert(s1,s2,p) string s1 with s2 inserted
int(x) integer portion of x
justify(a,n,w) elements array a as string justified to
width w
justify(a,n,w,c) elements array a as string justified to
width w
length number of characters in $0
length(s) number of characters in s
log(x) natural logrithm of x
log10(x) logrithm base 10 of x
match(s,r) position of r in s or 0 sets RSTART
and RLENGTH
overlay(s1,s2,p) string s1 overlayed
with s2 at p
pd_sym(name) pre-defined symbol with
name equal to string name
pd_sym(name) pre-defined symbol with
position in symbol table == n
pi ã 3.14159...
pi() ã 3.14159...
rand() random number 0 <= rand < 1
remove(s,c) string s with c's removed
replace(s) string s with
sub-expressions replaced
rotate(a) rotated array a
sdate(f) current system date
formated as string
sin(x) sine of x x in rad./deg.
sinh(x) hyperbolic sine of x
split(s,a) number of fields split s into
a on FS
split(s,a,fs) number of fields split s into
a on fs
sprintf(f,e,...) formatted string
srange(c1,c2) string from c1 to
c3 inclusive
srev(s) string s with characters
reversed
sqrt(x) square root of x
srand(seed) random number generator
seed
stime(f) current system time
formatted as string
stran(s) string s with
characters translated
stran(s,st) string s with
QTAwk - 11 - QTAwk
QTAwk 4.20 QTAwk
characters translated
stran(s,st,sf) string s with
characters translated
strim(s) string s with leading
& trailing white space removed
strim(s,le) string s with leading
expression and trailing
white space removed
strim(s,le,te) string s with leading
& trailing expression
removed
strlwr(s) s tranlated to lower case
strupr(s) s tranlated to upper case
sub(r,s) number of substitutions substitute s for
first r in $0
sub(r,s,t) number of substitutions substitute s for
first r in t
substr(s,p) substring of s from p
to end
substr(s,p,n) substring of s from p
of length n
system(s) exit status execute command s
ud_sym(name) user-defined symbol
with name equal
to string name
ud_sym(name) user-defined symbol
with position in
symbol table == n
The numeric function srand(x) sets a new seed for the random
number generator. srand() sets the seed from the current system
time.
The regular expression arguments of sub, gsub, match and strim
may be either regular expressions delimited by slashes or any
expression. If not a regular expression, the expression is
coerced to a string and the resulting string is converted into a
regular expression. This coersion and conversion occurs every
time the procedure is called so the regular expression form will
always be faster.
The print, printf and fprintf statements come in several forms:
Form Meaning
print; print $0 on standard output
QTAwk - 12 - QTAwk
QTAwk 4.20 QTAwk
print expression, ...; prints expressions
separated by OFS
print(expression, ...); prints expressions
separated by OFS
printf format, expression, ...; prints expressions formated
by "format"
printf(format, expression, ...); prints expressions formated
by "format"
fprint file; print $0 to "file"
fprint(file); print $0 to "file"
fprint file,expression, ...; prints expressions separated
by OFS to "file"
fprint(file,expression, ...); prints expressions separated
by OFS to "file"
fprintf file,format,expression, ...; prints expressions formated
by "format" to "file"
fprintf(file,format,expression, ..); prints expressions formated
by "format" to "file"
close(file) close "file"
The [f]print statement prints its arguments on the standard
output, or the specified file, separated by the current output
field separator, and terminated by the output record separator.
The [f]printf statement formats its expression-list according to
the format. The file is only opened once unless it is closed
between executions of the fprint[f] statement. A file that is
open for output must be closed if it is to be used for input. The
"file" argument may be any expression that evaluates to a DOS
file name.
There are two functions used for input:
Form Meaning
getline read the next record into $0
getline s read the next record into s
getline(s) read the next record into s
fgetline(file) read a record from "file" into $0
fgetline(file,s) read a record from "file" into s
getc() read a single character from current
input file
fgetc(file) read a single character from "file"
[f]getline returns -1 if there is an error (such as non
existent file), 0 on end of file and the number of characters
read otherwise.
QTAwk - 13 - QTAwk
QTAwk 4.20 QTAwk
The current input line and fields and variables NF, NR and FNR
are set by the forms of [f]getline according to the following
table:
³ getline();
³ getline; getline(v); fgetline(F); fgetline(F,v);
ÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
$0 ³ set not set set not set
$i ³ set not set set not set
NF ³ set not set set not set
NR ³ set set not set not set
FNR ³ set set not set not set
[f]getc returns the character read or -1 on a read error. 0 is
returned if the end of file is reached. If the current input
file, for 'getc', or "file", for 'fgetc', is the standard input
file and has not been redirected away from the keyboard, either
function will return zero, 0, for keystrokes which cannot be
represented by an ASCII character. A second call must be made to
obtain the extended ASCII character. If the second call also
returns zero, then an end of file has been reached.
The "for ( i in a )" statement assigns to 'i' the indices of 'a'
for all elements in 'a'. The sequencing of the values of 'i'
start with any integer values, low to high, then any string
values following the ASCII collating sequence (the same sequence
as used by the C strcmp functions.
The "while ()", "do ... while ()", "for (;;)", "break" and
"continue" statements are as in C. the "switch/case" statements
are as in C, except that that "case" labels may be any valid
QTAwk expression list. The following logic is followed in
matching "case" labels to the "switch" expression value:
if ( case_label_value == regular expression )
switch_value ~~ case_label_value
else switch_value == case_label_value
The "next" statement stops processing the pattern/action
statements, reads in the next record and restarts the
patterns/actions with the first.
The "cycle" statement will check the current value of
CYCLE_COUNT against the value of MAX_CYCLE and perform the
following actions: (CYCLE_COUNT is initialized to 1 every time a
new record is read from the current input file)
QTAwk - 14 - QTAwk
QTAwk 4.20 QTAwk
1. CYCLE_COUNT > MAX_CYCLE --> perform same action as "next"
statement.
2. CYCLE_COUNT <= MAX_CYCLE --> increment CYCLE_COUNT and
restart pattern/action processing with current values of NF,
NR, FNR, $0 and $i, 1 <= i <= NF
An "exit" statement will cause the END actions to be performed
or if encountered in an END action will cause termination of the
program. The optional expression is returned as the exit status
unless overridden by a further exit statement in an END action.
An "endfile" statement simulates an end-of-file on the current
input file. Any remaining pattern/action pairs are skipped and
any FINAL actions are executed before proceesing the next command
line argument.
The "return" statement may be used only in function
declarations. It may have an optional value which is returned as
the value of the function. The value of a function defaults to
zero/null string (0/"").
REGULAR EXPRESSIONS
^ matches Beginning of Line as first character of expression
$ matches End of Line as last character of expression
\c matches following (hexadecimal value shown in parenthesis):
\a == bell (alert) ( \x07 )
\b == backspace ( \x08 )
\f == formfeed ( \x0c )
\n == newline ( \x0a )
\r == carriage return ( \x0d )
\s == space ( \x20 )
\t == horizontal tab ( \x09 )
\v == vertical tab ( \x0b )
\c == c [ \\ == \ ]
\ooo == character represented by octal value ooo
1 to 3 octal digits acceptable
\xhh == character represented by hexadecimal value hh
1 or 2 hexadecimal digits acceptable
. matches any character
[abc0-9] Character Class - match any character in class
[^abc0-9] Negated Character Class - match any character
not in class
[!abc0-9] Negated Character Class - match any character
not in class
QTAwk - 15 - QTAwk
QTAwk 4.20 QTAwk
[#abc0-9] Matched Character Class - for second match,
class character must match in corresponding position
* - Closure, Zero or more matches
+ - Positive Closure, One or More matches
? - Zero or One matches
r(s)t embedded regular expression s
r|s|t '|' == logical 'or' operator. Expression r or s or t
@ - Look-Ahead, r@t, matches regular expression 'r' only when r
is followed by regular expression 't'.
Regular expression t not contained in final match.
Symbol loses special meaning when contained within
parenthesis, '()', or character class, '[]'.
r{n1,n2} - at least n1 and up to n2
repetitions of expression r
n1, n2 integers with 1 <= n1 <= n2
rrr?r?r?r? ==> rrr?r?r?r?
rrr ==> rrr
Expressions grouped by ", (), [], or names, "{name}"
repeated as a group:
(Note the treatment of quoted expressions)
(r)(r)(r)?(r)?(r)?(r)? ==> (r)(r)(r)?(r)?(r)?(r)?
[r][r][r]?[r]?[r]?[r]? ==> [r][r][r]?[r]?[r]?[r]?
{r}{r}({r})?({r})?({r})?({r})? ==> {r}{r}{r}?{r}?{r}?{r}?
"rr(r)?(r)?(r)?(r)?" ==> "rr(r)?(r)?(r)?(r)?"
{named_expr} - named expression. In regular expressions "{name}"
is replaced by the value of the corresponding variable.
Unrecognized variable names are not replaced. Names starting with
an underscore and followed by a single upper or lower case letter
are reserved as predefined. The following predefined names are
currently available:
{_a} == [A-Za-z] Alphabetic
{_b} == [{}()[]<>] Brackets
{_c} == [\x001-\x01f\x-7f] Control character
{_d} == [0-9] Digit
{_e} == [DdEe][-+]?{_d}{1,3} Exponent
{_f} == [-+]?({_d}+\.{_d}*|{_d}*\.{_d}+)
Floating point number
{_g} == {_f}({_e})? float, optional exponent
{_h} == [0-9A-Fa-f] Hex-digit
{_i} == [-+]?{_d}+ Integer
{_n} == [A-Za-z0-9] alpha-Numeric
{_o} == [0-7] Octal digit
{_p} == [\!-/:-@[- {-\x07f]
{_q} == {_s}[\"'] double or single Quote
{_r} == {_f}{_e} Real number
QTAwk - 16 - QTAwk
QTAwk 4.20 QTAwk
{_s} == (^|[!\\](\\\\)*) zero or even number of Slashes
{_t} == [\s-~] printable character
{_u} == [\!-~] graphical character
{_w} == [\s\t] White space
{_z} == [\t-\r\s] space, \t, \n, \v, \f, \r, \s
PRINTF FORMAT
QTAwk follows the ANSI standard for the C Language for the
format string in the printf and fprintf functions except for the
'P' and 'n' types, which are not supported and will give
unpredictable results.
A format specification has the form:
%[flags][width][.precision][h | l | L]type
which is matched by the following regular expression:
/%{flags}?65?{precision}?[hlL]?{type}/
with:
flags = /[-+\s#0]/;
width = /({_d}+|\*)/;
precision = /(\.({_d}+|\*))/;
type = /[diouxXfeEgGcs]/;
Each field of the format specification is a single character or
a number signifying a particular format option. The type
character, which appears after the last optional format field,
enclosed in braces '[..]', determines whether the associated
argument is interpreted as a character, a string, or a number.
The simplest format specification contains only the percent sign
and a type character (for example, %s). The optional fields
control other aspects of the formatting, as follows:
flags ==> Control justification of output and printing of signs,
blanks, decimal points, octal and hexadecimal prefixes.
width ==> Control minimum number of characters output.
precision ==> Controls maximum number of characters printed for
all or part of the output field, or minimum number of digits
printed for integer values.
QTAwk - 17 - QTAwk
QTAwk 4.20 QTAwk
h, l, L ==> Prefixes that determine size of argument expected
(this field is retained only for compatibility to C format
strings).
h ==> Used as a prefix with the integer types d, i, o, x, and X
to specify that the argument is short int, or with u to
specify a short unsigned int
l == > Used as a prefix with d, i, o, x, and X types to specify
that the argument is long int, or with u to specify a long
unsigned int; also used as a prefix with e, E, f, g, and G
types to specify a double, rather than a float
L ==> Used as a prefix with e, E, f, g, and G types to specify a
long double
If a percent sign, '%', is followed by a character that has no
meaning as a format field, the character is simply copied to the
output. For example, to print a percent-sign character, use "%%".
Type characters:
d ==> integer, Signed decimal integer
i ==> integer, Signed decimal integer
u ==> integer, Unsigned decimal integer
o ==> integer, Unsigned octal integer
x ==> integer, Unsigned hexadecimal integer, using "abcdef"
X ==> integer, Unsigned hexadecimal integer, using "ABCDEF"
f ==> float, Signed value having the form [-]dddd.dddd, where
dddd is one or more decimal digits. The number of digits
before the decimal point depends on the magnitude of the
number, and the number of digits after the decimal point
depends on the requested precision. e ==> float, Signed value
having the form [-]d.dddd e [sign]ddd, where d is a single
decimal digit, dddd is one or more decimal digits, ddd is
exactly three decimal digits, and sign is + or -.
E ==> float, Identical to the e format, except that E introduces
the exponent instead of e.
g ==> float, Signed value printed in f or e format, whichever is
more compact for the given value and precision. The e format
is used only when the exponent of the value is less than -4
or greater than the precision argument. Trailing zeros are
truncated and the decimal point appears only if one or more
digits follow it.
G ==> float, Identical to the g format, except that G introduces
the exponent (where appropriate) instead of e.
QTAwk - 18 - QTAwk
QTAwk 4.20 QTAwk
c ==> character, Single character
s ==> string, Characters printed up to the first null character
('\0') or until the precision value is reached.
Flag Characters
- ==> Left justify the result within the given field width.
Default: Right justify.
+ ==> Prefix the output value with a sign (+ or -) if the output
value is of a signed type. Default: Sign appears only for
negative signed values (-).
blank (' ') ==> Prefix the output value with a blank if the
output value is signed and positive. The blank is ignored if
both the blank and + flags appear. Default: No blank.
# ==> When used with the o, x, or X format, the # flag prefixes
any nonzero output value with 0, 0x, or 0X, respectively.
Default: No blank.
# ==> When used with the e, E, or f format, the # flag forces
the output value to contain a decimal point in all cases.
Default: Decimal point appears only if digits follow it.
# ==> When used with the g or G format, the # flag forces the
output value to contain a decimal point in all cases and
prevents the truncation of trailing zeros. Default: Decimal
point appears only if digits follow it. Trailing zeros are
truncated.
# ==> Ignored when used with c, d, i, u or s
0 ==> For d, i, o, u, x, X, e, E, f, g, and G conversions,
leading zeros (following any indication of sign or base) are
used to pad to the field width; no space padding is
performed. If the 0 and - flags both appear, the 0 flag will
be ignored. For d, i, o, u, x, and X conversions, if a
precision is specified, the 0 flag will be ignored. For other
conversions the behavior is undefined. Default: Use blank
padding
If the argument corresponding to a floating-point specifier is
infinite or indefinite, the following output is produced:
+ infinity ==> 1.#INFrandom-digits
QTAwk - 19 - QTAwk
QTAwk 4.20 QTAwk
- infinity ==> -1.#INFrandom-digits
Indefinite ==> digit.#INDrandom-digits
The width argument is a non-negative decimal integer controlling
the minimum number of characters printed. If the number of
characters in the output value is less than the specified width,
blanks are added to the left or the right of the values
(depending on whether the - flag is specified) until the minimum
width is reached. If width is prefixed with a 0 flag, zeros are
added until the minimum width is reached (not useful for
left-justified numbers).
The width specification never causes a value to be truncated; if
the number of characters in the output value is greater than the
specified width, or width is not given, all characters of the
value are printed (subject to the precision specification).
The width specification may be an asterisk (*), in which case an
integer argument from the argument list supplies the value. The
width argument must precede the value being formatted in the
argument list. A nonexistent or small field width does not cause
a truncation of a field; if the result of a conversion is wider
than the field width, the field expands to contain the conversion
result.
The precision specification is a non-negative decimal integer
preceded by a period, '.', which specifies the number of
characters to be printed, the number of decimal places, or the
number of significant digits. Unlike the width specification, the
precision can cause truncation of the output value, or rounding
in the case of a floating-point value.
The precision specification may be an asterisk, '*', in which
case an integer argument from the argument list supplies the
value. The precision argument must precede the value being
formatted in the argument list.
The interpretation of the precision value, and the default when
precision is omitted, depend on the type, as shown below:
d,i,u,o,x,X ==> The precision specifies the minimum number of
digits to be printed. If the number of digits in the argument
is less than precision, the output value is padded on the
left with zeros. The value is not truncated when the number
of digits exceeds precision. Default: If precision is 0 or
omitted entirely, or if the period (.) appears without a
QTAwk - 20 - QTAwk
QTAwk 4.20 QTAwk
number following it, the precision is set to 1.
e, E ==> The precision specifies the number of digits to be
printed after the decimal point. The last printed digit is
rounded. Default: Default precision is 6; if precision is 0
or the period (.) appears without a number following it, no
decimal point is printed.
f ==> The precision value specifies the number of digits after
the decimal point. If a decimal point appears, at least one
digit appears before it. The value is rounded to the
appropriate number of digits. Default: Default precision is
6; if precision is 0, or if the period (.) appears without a
number following it, no decimal point appears.
g, G ==> The precision specifies the maximum number of
significant digits printed. Default: Six significant digits
are printed, without any trailing zeros that are truncated.
c ==>No effect. Default: Character printed
s ==> The precision specifies the maximum number of characters
to be printed. Characters in excess of precision are not
printed. Default: All characters of the string are printed.
EXAMPLES
Print lines longer than 72 characters (missing action is print):
length($0) > 72
or
length > 72
Print first two fields in opposite order (missing pattern is
always match):
{ print $2, $1; }
Add up first column, print sum and average:
{ s += $1; }
END { print "sum is", s, "average is", s/NR }
Print fields in reverse order:
QTAwk - 21 - QTAwk
QTAwk 4.20 QTAwk
{ for ( i = NF ; i > 0 ; --i ) print $i; }
Print all lines between start/stop pairs:
/start/,/stop/
Print all lines whose first field is different from previous
one:
$1 != prev { print; prev = $1; }
Convert date from MM/DD/YY to metric (YYMMDD):
{ n = split(sdate(0),a,"/"); date = a[3] ï a[1] ï a[2] }
Copy a C program and insert include files:
$1 == "#include" && $2 ~~ /^"/ {
local tfile = $2;
gsub(/"/, "",tfile);
while ( fgetline(tfile,tmp) > 0 ) print tmp;
next;
}
{ print; }
AUTHOR
QTAwk
Utility Creation Program
Version 4.20 10-10-90
(c) Copyright 1988 - 1990 Pearl Boldt. All Rights Reserved.
Pearl Boldt
Quik Trim
13012 Birdale Lane
Darnestown, MD 20878
CompuServe ID: 72040.434
Registration Information
QTAwk is a copyrighted program protected by both U.S. and
international copyright law. If you obtained QTAwk from a
shareware disk vendor, an on-line computer service or bulletin
board, a friend or colleague, or another similar source, you have
an unregistered (trial) copy. You may use this copy without
QTAwk - 22 - QTAwk
QTAwk 4.20 QTAwk
charge for a limited period of time under the terms of the QTAwk
license agreement (below). After this time is up, you must
register and pay for QTAwk to continue using it.
This method of distribution is known as shareware. It allows you
to determine whether QTAwk meets your needs before you pay for
it.
The registration fee for a single copy of QTAwk is $50. Payment
of this fee entitles you to:
* A disk with the latest version of QTAwk, registered to you.
* One copy of the printed QTAwk manual.
* An upgrade to the next release of QTAwk.
* Technical support via electronic mail or telephone.
If you prefer, you may register for $35 and receive only the
disk and notices of future upgrades. Network, site, and corporate
licenses are also available; contact the copyright holder for
more information.
Upgrade Information
If you purchased QTAwk version 4.02 or later at the $50 rate, or
a site license for version 4.02 or later, you are entitled to a
free upgrade to version 4.20. If you are not entitled to a free
upgrade, or you wish to order a version 4.20 manual use the order
form following the License Agreement.
QTAwk License Agreement
1. Copyright: The QTAwk program and all other programs and
documentation distributed or shipped with it are Copyright
1988 - 1990 Pearl Boldt and are protected by U.S. and
International Copyright law. In the rest of this document,
this collection of programs is referred to simply as "QTAwk".
You are granted a license to use your copy of QTAwk only
under the terms and conditions specified in this license
agreement.
2. Definitions: QTAwk is distributed in two forms. A
"registered" copy of QTAwk is a copy distributed on diskette,
purchased from the copyright holder. A "shareware" copy of
QTAwk - 23 - QTAwk
QTAwk 4.20 QTAwk
QTAwk is a copy distributed on diskette or via an electronic
bulletin board, on-line service, or other electronic means,
obtained from a shareware disk vendor, or obtained from
another individual.
3. Shareware Copies: Shareware copies of QTAwk are distributed
to allow you to try the program before you pay for it. They
are Copyright 1988 - 1990, Pearl Boldt and do not constitute
"free" or "public domain" software. You may use a shareware
copy of QTAwk at no charge for a trial period of up to 21
days. If you wish to continue using QTAwk after that period,
you must purchase a registered copy. If you choose not to
purchase a registered copy, you must stop using QTAwk, though
you may keep copies and pass them along to others. You may
give QTAwk to others for noncommercial use IF:
=> All Files And Documentation Accompany The Programs.
=> The Files Are Not Modified In Any Way.
4. Registered Copies: Registered copies of QTAwk are
distributed to those who have purchased them from the
copyright holder.
5. Use of One Copy on Two Computers: If you have a registered
copy of QTAwk which is licensed for use on a single computer,
you may install it on two computers used at two different
locations (for example, at work and at home), provided there
is no possibility that the two computers will be in use at
the same time, and provided that you yourself have purchased
QTAwk, or if QTAwk was purchased by your employer, that you
have your employer's explicit permission to install QTAwk on
two systems as described in this paragraph. The right to
install one copy of QTAwk on two computers is limited to
copies originally licensed for use on a single computer, and
may not be used to expand the number of systems covered under
a multi-system license.
6. Use of QTAwk on Networks or Multiple Systems: You may
install your registered copy of QTAwk on a computer attached
to a network, or remove it from one computer and install it
on a different one, provided there is no possibility that
your copy will be used by more users than it is licensed for.
A "user" is defined as one keyboard which is connected to a
computer on which QTAwk is installed or used, regardless of
whether or not the user of the keyboard is aware of the
installation or use of QTAwk in the system.
QTAwk - 24 - QTAwk
QTAwk 4.20 QTAwk
7. Making Copies: You may copy any version of QTAwk for normal
backup purposes, and you may give copies of the shareware
version to other individuals subject to paragraph (4) above.
You may not give copies of the registered version to any
other person for any purpose, without explicit written
permission from the copyright holder.
8. Distribution Restrictions: You may NOT distribute QTAwk
other than through individual copies of the shareware version
passed to friends and associates for their individual,
non-commercial use. Specifically, you may not place QTAwk or
any part of the QTAwk package in any user group or commercial
library, or distribute it with any other product or as an
incentive to purchase any other product, without express
written permission from the copyright holder and you may not
distribute for a fee, or in any way sell copies of QTAwk or
any part of the QTAwk package. If you are a shareware disk
vendor approved by the Association of Shareware Professionals
(ASP), you may place QTAwk in your library without prior
written permission, provided you notify the copyright holder
within 15 days of doing so and provided your application has
been fully approved in writing by the ASP, and is not simply
submitted or awaiting review.
9. Use of QTAwk: QTAwk is a powerful program. While we have
attempted to build in reasonable safeguards, if you do not
use QTAwk properly you may destroy files or cause other
damage to your computer software and data. You assume full
responsibility for the selection and use of QTAwk to achieve
your intended results. As stated below, the warranty on QTAwk
is limited to replacement of a defective program diskette or
manual.
10. LIMITED WARRANTY: All warranties as to this software,
whether express or implied, are disclaimed, including without
limitation any implied warranties of merchantability, fitness
for a particular purpose, functionality or data integrity or
protection are disclaimed.
11. Satisfaction Guarantee: If you are dissatisfied with a
registered copy of QTAwk for any reason (whether or not you
find a software error or defect), you may return the entire
package at any time up to 90 days after purchase for a full
refund of your original registration fee.
Questions may be sent to:
QTAwk - 25 - QTAwk
QTAwk 4.20 QTAwk
Pearl Boldt
Quik Trim
13012 Birdale Lane
Darnestown, MD 20878
CompuServe ID: 72040.434
SEE ALSO:
A. V Aho, B. W Kernighan, P. J. Weinberger,
"The AWK Programming Language"
Addison-Wesley 1988 ISBN 0-201-07981-X
QTAwk - 26 - QTAwk
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/