agen: generate lines according to variables and patterns and put the lines onto the standard output Usage: agen -v {variable} [expr1] [expr_n...] The variables must be specified with range definitions. The output expressions refer to the variables in the $(variable) form. Each expression generate a separate line (and this will be multiplied by the number of the generating ranges, too). (Notes on Unices: the output formatting strings must be guarded with '-s, instead of "-s. Otherwise the shell will replace the $(varname) references with the values of the environment variables (likely empty strings). The examples show it all). If there are several variables, the result will contain each permutation of the possible values. The evaluation order corresponds to the definition order of the variables. Variables can be bound together: in this case, instead of the permutation the corresponding values (by index) will be taken. The format of binding is: [variable1,variable2,...] If the bounded variable ranges are not of the same size, the smaller one will give the numbers of items. Parameters: -c: use the COUNTER variable automatically (contains the number of the current line) -cw {width}: specify a width for the counter -cf {char}: specify a filler character for the COUNTER (by default, the filler is space) -s {max_size}: specify the max size (number of bytes) on the output The output is closed when this value is exceeded. If the last character of the value is 'k'/'K', the meaning is kilobytes. If the value ends with 'm'/'M', it means megabytes. -bs {max_size}: nearly the same as the previous one, but this stops printing _before_ the size is exceeded -cnt {var_def}: specifies a counter with the given value. Counters iterate over the values as the generated lines are populated (restart if the end of the range is reached). Any number of counters can be defined, each of them runs in its own range (but they don't specify the number of output lines). The vraibles can be used in the format strings with the '$(varname)' form. -l {number}: specify the number of lines to be printed. If this value is less than the generated set, the printing will end at this number of lines. If this value is greater than the generated set, the line generation will restart (as many times as necessary) end ends when this value is reached. -m {number} {pattern}: multiply the pattern by the given number. For simple (counted) lists this method is more time effective, than the direct usage of variables. The result is n lines of text. The COUNTER variable can be used in the patter (starts at 0). Additional (formatting) options for the variables (these settings apply to the counter variables, too): -multiplication: '$(APPLE*5)': the value of the APPLE variable will be used 5 times after each other -width specification: '$(APPLE:10)': the substituted value will be aligned to 10 characters (if longer, it will be truncated). Positive numbers mean alignment to the left, negative values mean alignment to the right. -width alighment filling: '$(APPLE:10@_)': if the value is longer than 10 chars on the right part (that extend the output to the expected width) will be filled with underscores. Examples: agen 10 -> print the numbers in [0..10] agen 10 20 30 40 -> print the numbers in [10..20] [30..40] agen -m 10 "This is line @ $(COUNTER)" -> Prints 10 lines with the apprpriate line number. agen -v "APPLE=[1-10]" '$(APPLE)' -> generate lines in the range 1-10 (with each value) agen -v "APPLE=[1-5,10-15]" '$(APPLE)' -> gives lines with 1,2,3,4,5,10,11,12,13,14,15 agen -v "APPLE=[10-30]" 'Text with numbers: $(APPLE) - the rest of the line' -> gives: Text with numbers: 10 - the rest of the line -"- 11 -"- ... agen -v "APPLE=[5-7]" '$(APPLE)' '$(APPLE) once again' -> each item (5,6,7) generate two lines, like: 5 5 - once again 6 ... agen -v "APPLE=[1-10]" -cnt "C1=[a,b,c]" '$(A) - $(C1)' -> 1 - a 2 - b 3 - c 4 - a ... agen -v "APPLE=[1-5]" '$(APPLE)' -l 12 -> the range will be printed two times + '1', '2' agen -v "APPLE=[mac,iphone,ipad]" 'product: $(APPLE)' -> the out lines will be: product: mac product: iphone product: ipad agen -v "FRUIT=[apple,plum,apricot]" -v "PRODUCT=[fruit,juice,jam]" "$(FRUIT) -> $(PRODUCT)" -> Each FRUIT value will be used, so that the PRODUCT values will follow each one of them. The first lines will be: apple -> fruit apple -> juice apple -> jam plum -> fruit plum -> juice ... agen -v "FRUIT=[apple,plum,apricot]" -v "PRODUCT=[fruit,juice,jam]" "$(FRUIT) -> $(PRODUCT)" [FRUIT,PRODUCT] -> In this case the FRUIT and PRODUCT variables 'run together', with this result: apple -> fruit plum -> juice apricot -> jam agen -v "FRUIT=[rand(apple,plum,apricot)]" 'pick it: $(FRUIT)' -> each value will be picked, in random order agen -v "FRUIT=[rand(apple,plum,apricot)*5]" 'pick it: $(FRUIT)' -> five values will be picked randomly from the given items agen -v "NUMBER=[rand(1,2,3)*10]" -c -cw 3 -cf "_" '$(COUNTER): $(NUMBER)' -> generate 10 lines with line number and random numbers, like this: __0: 3 __1: 2 __2: 2 and so on... agen -v "NUMBER=[perm(123)]" '$(NUMBER)' -> each permutation of "123" will be printed agen -v "NUMBER=[perm(bcda)*5]" '$(NUMBER)' -> 5 permutations will be printed agen -v "FRUIT=[rand(apple,plum,apricot)*10000]" '$(FRUIT)' -s 16k -> random fruits will be picked, the printing ends if the output exceeds the 16384 bytes limit (the result can be a bit longer than this value, depending on the last fruit) agen -v "FRUIT=[rand(apple,plum,apricot)]" '$(FRUIT:10@_*3)' -> the randomly picked fruits will be suffixed with underscores and then repeated 3 times, example: apple_____apple_____apple_____ apricot___apricot___apricot___ agen -v "a=[rand(1-10)*10]" -v "b=[rand(11-20)*10]" "$(a:-3)|$(b:-3)" [a,b] -> generate ten lines with random number pairs (aligned to right) example: 3| 12 9| 20