1 | 2 | 3 | 1 | 4 | 7 | 10 | |
4 | 5 | 6 | would become | 2 | 5 | 8 | 11 |
7 | 8 | 9 | 3 | 6 | 9 | 12 | |
10 | 11 | 12 |
E.g., given input file
%DEFINE kieli latina
%DEFINE kissa felis domesticus
Kissa on %kieli%ksi "%kissa%"!
it would print
Kissa on latinaksi "felis domesticus"!
euler.it IN A 130.234.160.43 ; vanha nimbus IN HINFO HP-9000/835 UNIX INFO "Tietotekniikka AgC425.1" ALIAS euler.mit ALIAS nimbus1.mit ETHER 08000902ED2B IN MX 0 badmail.itLines beginning with semicoln are comments, for indented lines machine name is taken from the previous line (i.e., same as on last non-indented non-comment line). Indentations and field separators can be spaces or tabs. Blank lines are ignored.
IP addresses are always on 'IN A' line's last field as four dot-separated numbers 0-255.
Write a script freeip, that finds unused addresses within
given range. The range is given as argument like this:
freeip 192.168.1.1-128
i.e., only last part as a range.
By default the initial part is assumed to be 130.234. (i.e., freeip 160.25-128 would be same as freeip 130.234.160.25-128) and if last part is omitted, it'll default to 25-255 (only the third part is required).
KEY ALPHA 3 KEY BETA 1 ALPHA note 1 and some junk GAMMA junk BETA something DELTA who cares about this KEY DELTA 4 ALPHA me too KEY BETA 0 DELTA this is important (maybe) BETA this is junk ...Write a script that processes it as follows:
Lines beginnning with KEY define how many fields will be printed for lines beginning with corresponding key.
E.g., KEY ALPHA 2 means that for lines beginning with ALPHA after that will be printed with two first fields (including the word ALPHA), KEY BETA 0 that lines beginning with BETA will not be printed at all thereafter. So, for the input above it'd print
ALPHA note 1 BETA ALPHA me too DELTA this is importantThe number of keys and fields is arbitrary and they can have any visible characters (no spaces, tabs or newlines). Fields are separated by spaces only.