awkium: an awk interpreter


Japanese - Top - How to Use - awkium language - libraries - awkium File System - awkium shell - awkium sed - download

awkium includes a bsh-like shell.
Warning: In this version, OS native commands can not execute.


Syntax of awkium shell

syntax is similar to bsh.
$  [] ...
if command1
then
  command-block1
[ elif command2
then
  command-block2
[ ...
[ else
  command-blockn
fi]]]
execute <command-block1> if error code of <command1> is true(0). otherwise, execute <command-block2> if error code of <command2> is true. execute <command-block2> if all conditions are not true.

for variable in value ...
do
  command-block
done
assign each <value> to <variable> and execute <command-block>.

case variable in
pattern1) command-block1 ;;
[ pattern2) command-block2 ;; 
[ ...
esac]]
execute <command-block> if the value of <variable> matches <pattern>.
Alternation delimitered by '|' is available in <pattern>.

while command
do
  command-block
done
execute <command-block> while the error code of <command> is true.

until command
do
  command-block
done
execute <command-block> while the error code of <command> is not true.

command1 && command2
execute <command2> if <command1> is true.

command1 || command2
execute <command2> if <command1> is not true.

command1 | command2
The standard output of <command1> connects the standard input of <command2> (pipe).

command < filename
The standard input of the command redirects to the given file.

command << string


Here-document

command > filename
The standard output of the command overrides to the given file.

command >> filename
The standard input of the command appends to the given file.

;
specify the end of command. This character is similar to newline.

! command
execute <command> and returns 0 if its error code is not 0, otherwise return non-zero if it is 0.

variable-name=value
assigns value to the variable.

break
leave the innermost enclosing loop.

continue
skip to reinitialization of the innermost enclosing loop.

return
return from a shell function.

exit [exit-code]
exit from the shell.

function function-name {
  command-block
}
define a function. The way to call functions is similar to ordinary commands.

function-name () {
  command-block
}
define a function.

eval [argument ...]
evalate the arguments.


commands

. [script]
execute the script file.

source [script]
execute the script file.

:
return the error code 0.

[ [codition] ]
evaluate the codition. The conditions are available shown as follows.
The priority of the operators are -o < -a < !.
-a file return 0 if file is exist
-d file return 0 if file is a directory
-e file return 0 if file is exist
-f file return 0 if file is an ordinary file
-r file return 0 if file is readable
-s file return 0 if the size of file is not 0
-w file return 0 if file is writable
-x file return 0 if file is executable
-z string return 0 if the length of string is 0
-n string return 0 if the length of string is not 0
file1 -nt file2 return 0 if file1 is newer than file2
file1 -ot file2 return 0 if file1 is older than file2
string1 = string2 return 0 if string1 is equal to string2
string1 != string2 return 0 if string1 is not equal to string2
string1 < string2 return 0 if string1 is less than string2
string1 <= string2 return 0 if string1 is not more than string2
string1 > string2 return 0 if string1 is more than string2
string1 >= string2 return 0 if string1 is not less than string2
string1 -eq string2 return 0 if string1 is equal to string2 as a number
string1 -ne string2 return 0 if string1 is not equal to string2 as a number
string1 -lt string2 return 0 if string1 is less than string2 as a number
string1 -le string2 return 0 if string1 is not more than string2 as a number
string1 -gt string2 return 0 if string1 is more than string2 as a number
string1 -ge string2 return 0 if string1 is not less than string2 as a number
expression1 -o expression12 return 0 if more than one of the expressions is 0.
expression11 -a expression12 return 0 if all the expressions is 0.
! expression11 return 0 if expression is 0 or non-0 if expression is not 0
( expression1 ) return expression1

awk [options] [file ...]
execute awkium.

basename pathname
extract filename from the given pathname.

builtin command
execute command as a built-in command.

cat [options] file ...
display file to a standard input.
-b, --number-nonblank display a line number if the line is not empty
-e identical to -vE
-n, --number display a line number
-s, --squeeze-blank squeeze empty lines
-t idential to -vT
-v, --show-nonprinting convert a tab character to "~" and non-ASCII characters to "M-"
-A, --show-all identical to -vET
-E, --show-ends display "$" to the end of lines
-T, --show-tabs convert a tab character to "^I"

cd directory
move current directory to the directory.

command command
execute command as a command.

cp [options] file ...
copy file.
-f force copy if file is exist
-H reserved
-i copy interactive
-L reserved
-p reserved
-r, -R copy file recursively

cut [options] file ...
cut a part of a line.
-s, --only-delimited ignore lines which do not have any delimiters
-d delim, --delimiter=delim specify the delimiter
-b start[-end], --bytes=start[-end] display specified bytes
-c start[-end], --characters=start[-end] display specified characters
-f start[-end], --fields=start[-end] display specified fields

d [options] file ...
display the infomation of the give files (correspond to UNIX ls or Windows dir).
-F add the end of filename to "/" if it is a directory
-R display file recursively
-a display hidden files
-d not display if the given file is a directory
-q reserved
-r reverse sort
-1 display only filename a line
-t sort by modified time

date [options] [+format] [date]
display date.
-d date display the specified date
+format strftime(3) date format
date specify a date by MMDDHHmm[[CC]YY].ss format

dirname pathname
extract directory name from the pathname.

echo string
echo the string.
-n suppress the trailing newline
-e recognize espace sequences
-E not recognize espace sequences

export variable[=value] ...
export variable to environment.
Environment variables of OS is not changed.

false
return non-0 error code.

getopts options
analyse the options.

grep [options] pattern [file ...]
search the file by the given regular expression.
-A number display number lines after matching lines
-B number display number lines before matching lines
-C number display number lines before and after matching lines
-E reserved
-F use fixed patterns
-G use basic regular expression
-J use Java standard regular experssion
-b display an offset before lines.
-n display a line number
-c display only number of matched lines
-e pattern specify pattern
-f file read a pattern from file
-h suppress displaying filenames
-H display filenames
-i ignore cases
-l display only matched filenames
-q quiet node
-s suppress error message
-v invert match
-w match the whole word
-x match the whole line

head [options] [file ...]
display the head of file.
-q, --quiet not display filename
-v, --verbose display filename
-c num, --bytes num display the first num bytes (SI prefixes(k, M) are available)
-C num, --characters num display the first num characters (SI prefixes(k, M) are available)
-n num, --lines=num display the first num lines (SI prefixes(k, M) are available)
-num display the first num lines (SI prefixes(k, M) are available)

local [varname=value ...]
define a local variable.

mkdir [options] dir
make the given directory.
-p create parent directory of the directory

msgbox [options] message
display message to the message box window.
This command returns 0 if the result is OK, 1 if the result is NO or 2 if the result is Canceled.
-c display OK-Cancel message box
-y display Yes-No message box
-Y display Yes-No-Cancel message box
-q specify question as a message window icon
-i specify information as a message window icon
-w specify warninig as a message window icon
-e specify error as a message window icon

mv [options] [file ...]
move file.
-b make a backup if the destination file is exist
-f do not prompt before overwriting
-i prompt before overwrite
-u, -v reserved

pwd
display the current directory.

read [-r] [variable-name ...]
read a line from the standard input and assign it to the given variables.
-r not regard \ as a escape character

readonly [variable-name ...]
declare variables as read-only variables.

rm [options] [filename ...]
remove the files. This command can not remove recursively.
-f, --force do not prompt before removing
-i, --interactive prompt before removing
-v, --verbose display filenames to be removed

rmdir [options] [directory ...]
remove the directory.
-p, --parent remove parent directories

sed [options] command [file ...]
execute stream editor.
-n not display pattern spaces
-e command specify sed-command
-f file read sed-command from the file

set [options]
change configurations of the shell.
-C, +C, -o noclobber, +o noclobber (not) allow overwriting by redirection
-f, +f, -o noglob, +o noglob (not) allow expanding by wildcards
-n, +n, -o noexec, +o noexec (not) allow executing commands
-u, +u, -o nounset, +o nounset (not) allow unsetting variables
-v, +v, -o verbose, +o verbose (not) display commands to execute
-x, +x, -o xtrace, +o xtrace (not) trace commands

sh [options] [file ...]
execute in a sub shell.
-C, +C (not) allow overwriting by redirection
-f, +f (not) allow expanding by wildcards
-n, +n (not) allow executing commands
-u, +u (not) allow unsetting variables
-v, +v (not) display commands to execute
-x, +x (not) trace commands
-c command execute the given command
-s file execute the file interactively

shift num
shift arguments.

sleep sec
delay for sec seconds.

sort [options] [file ...]
sort the files.
-c check whether the files are sorted
-m merge the sorted files
-u not display the duplicated lines.
-t specify the delimiter
-o filename specify the output file
-b ignore leading spaces
-d consider only ASCII alphabets and digits
-f ignore cases
-i consider only ASCII characters
-M reserved
-n compare according to string numerical value
-r sort reversely
-k field specify files to sort

sqlc [options] SQL [argument ...]
execute SQL using JDBC.
-v display the number to processed
-d dbms specify DBMS
db2IBM DB2
firebirdFirebird
mssqlMicrosoft SQL Server
mysqlMySQL
oracleOracle
postgresqlPostgreSQL
sqliteSQLite
the environment variable DBMS is also available
-i specify JDBC URI. the environment variable DB_URI is also available
-u specify DB user. the environment variable DB_USER is also available
-p specify DB password. the environment variable DB_PASSWORD is also available

tail [options] [file ...]
display the tail of the files.
-q, --quiet not display filename
-v, --verbose display filename
-c num, --bytes num display the first num bytes (SI prefixes(k, M) are available)
-C num, --characters num display the first num characters (SI prefixes(k, M) are available)
-n num, --lines=num display the first num lines (SI prefixes(k, M) are available)
-num display the first num lines (SI prefixes(k, M) are available)

tee [options] file
output to the standard output and the given file.
-a, --append appends to the file

touch [options] [filename ...]
change file timestamps.
-c not create a file if the given filename is not exist
-d date, --date=date specify timestamp to the given date
-r file, --reference=file specify timestamp to timestamp of the file
-t date use MMDDhhmm[[[CC]YY].ss] instead of current time

tr [options] pattern1 pattern2
translate or delete characters.
-c complement pattern1
-d delete characters in pattern1
-s squeeze characters in pattern1
-t truncate the cardinality of pattern1 to pattern2

true
return the error code 0.

uniq [options] [file ...]
omit repeated lines.
-u, --unique display only unique lines
-d, --repeated display only repeated lines
-f num, --skip-fields=num skip num fields
-s num, --skip-chars=num skip num characters
-w num, --check-field=num check num characters

unset [variable-name ...]
unset variables.

wc [options] [file ...]
counts lines, words, characters and bytes.
-b, --bytes count and display bytes
-c, --chars count and display characters
-w, --words count and display words
-l, --lines count and display lines

wread [options] variable
display and assign the result to the given variable.
-q specify question as a message window icon
-i specify information as a message window icon
-w specify warninig as a message window icon
-e specify error as a message window icon