awkium: an awk interpreter


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

Command syntax of sed is as follows.

[addresses[!]]command


Following formats are available as address.
You can invert matching by adding "!" after address.

line-number1
execute a command at line-number1.

line-number1,line-number2
execute a command between line-number1 to line-number2.

/regexp1/[I][M]
execute a command at the line which matches regexp1 first.
Basic regular expression(BRE) is available on this implementation.
Regular expression can desribe as \%regexp%, where "%" is any character.
Flags shown as follows can be specified after /regexp/.

/regexp1/[I][M],/regexp2/[I][M]
start executing a command at the line which matches regexp1 first, and end at the line which matches it second.

line-number1,/regexp2/[I][M]
start executing a command at line-number1, and end at the line which matches regexp2 first.

/regexp1/[I][M],line-number2
start executing a command at the line which matches regexp1 first, and end at line-number2.

/regexp1/[I][M],+number
match /regexp1/ and the number lines following addr1.

g/regexp/[I][M]
match all lines which matches regexp.

$
match the last line.

line-number1,$
match between line-number1 to the end of the input.

/regexp1/[I][M],$
match between the first occurence of regexp1 and the end of the input.

line-number~number
match line-number and multiple of number from line-number.


Basic regular experssion(BRE) is available in awkium.

character
match a character.

.
match any character.

*
matched zero or more times.

\{n\}
matched exactly n times.

\{n,\}
matched n or more times.

\{n,m\}
matched at least n times, but not more than m times.

[character-set]
matches the given characters. Complement set is available.


\(regexp\)
capture the string which regexp matches.

^
match the beginning of line when "^" is a first character of regexp.

$
match the end of line when "$" is a last character of regexp.


Available commands in awkium are shown as follows.

s/regexp/substitution/flags
substitute strings.
flags shown as follows are available.
#
a comment line.

q
quit sed.

d
delete matched line.

p
print matched line.

n
print the current pattern space and input next line.

{command[,...]}
execute multiple commands.

y/characters1/characters2/
replace characters1 to characters2.

a\
text
append a text after matched line.

i\
text
insert a text after matched line.

c\
text
replace matched line to text

=
print current line number.

l
print matched line in a "visually unambiguous" form.

rfilename
read the file.

wfilename
write the current pattern space.

D
delete the first line of the pattern space.

N
append the input to the pattern space.

P
print the first line of the pattern space.

h
change the pattern space to the hold space.

H
append the pattern space to the hold space.

g
change the hold space to the pattern space.

G
append the hold space to the pattern space.

x
exchange the pattern space and the hold space.

:label
define a label.

blabel
go to label.

tlabel
go to label if a line replaced by last "s" command.