usage: aconv [expr1] [expr...] the program uses the std input as file names and writes the output with each expression (each expression uses new line) Parameters: -s {sep}: define the macro separator (see later at macros). The 'space' string can be used to define the space character as separator. -i {str}: define direct input. The 'str' will be processed as if it came from the std input. -p[attern] {input_pattern} {output_format}: define in and out patterns (see later) -out_sep/-os {sep}: define the output separator -v {variable}: variable definition. The type is defined with angle brackets after the variable name. Alternatively, also an initial value can be added, after the '='. -q[uiet] {expr}: evaluate the 'expr' for each incoming line (but don't print the result). These expressions are evaluated before the ones that generate an output string. -pq {expr}: these expressions are all evaluated _after_ the incoming lines -post {expr}: evaluate the 'expr' after the last line arrived (and print the result) -a {name}: use an alias for complex , possible values: - sum - ave - min - max -g: group the expressions. By default, the expressions generate separate lines. With this option each input line generates only one output line, contaning as many string as the number of the specified expressions. -os {s}: specify separator for the grouped output items, they will be separated with this string in the output lines. Any other parameter is interpreted as an expression to evaluate (and its result is put onto the std out as a separate line). The expressions are "normal" expressions, where the following variables can be used: -file: the whole file name (like 'root\apple.txt') -line: the same as 'file' -name: only file name ('apple') -path ('root') -ext ('txt', without the dot) -pathname (path+name) ('root\apple') -s[ep] {char}: define the separator for the macros (see later) The special symbols: - 'bs' = '\' - 'dot' ='.' - 'qm' ='"' These can be used in expressions in order not to obfuscate the command lines (avoid the \"-like things). Macros: the input can be tokenized with the -s parameter and the created tokens can be used in expressions, in the '${token number}' form. These macros can be used in the expressions ('$0' for the first column/token, '$1' for the second one and so on). See the examples (use the '-s, otherwise the shell will process the $-like expressions - with non-existing environment variables). Patterns: these formulas can be used to interpret the input (parse into variables) and use these variables to create/reformat the output. The variables are used in $(varname) form. Input: a variable definition eats any character from the input, until the separator character after its definition: '$(ONE),' <-- the variable 'ONE' will contain each character before the first comma. If the input string could not be parsed entirely properly (that is it didn't fit the pattern: variables and separator characters in the specified order), the variables remain empty. Output: the varibales ca be used in any place of the output formatter (see the examples) Variable definition and usage (after the -v parameter): name[=initial_value], like 'sum', 'more_sum=12' The type (between angle brackets, appended to the variable name) is compulsory. Possible types: int, double, string, point, complex. The initial value is optional, but must be a constant value (not an expression). Point and complex values must be defined between braces (...={1,2}, in x,y and re,im order, respectively). Examples: ... | aconv file : this simply forwards every input file name ... | aconv name ext : two lines are written for each input file name -> if the incoming file name is "apple.txt" the output is: apple txt ... | aconv "name + '_test.' + ext" : the '_test' is inserted into each line (like "root\apple_test.txt") ... | aconv path+bs+name+dot+ext -> gives the original name with path ("apple/ipad.txt") ... | aconv "strtok(line, '|', 1) + ' - ' + strtok(line, '|', 3)' -> gives the second and fourth column of the pipe-separated input, with a hyphen between them ... | aconv -s space "$2 + ',' + $0" -> gives the the third and first columns of the input, this time separated by comma (the other columns are skipped) ... | aconv -p '$(FIRST) $(SECOND)' '$(SECOND):$(FIRST)' -> the input is parsed into the variables (assumes space-separated columns) 'FIRST' and 'SECOND', and puts the values in reversed order, now separated with colons ... | aconv -v "counter" -q "counter += 1" -post counter -> counts the number of input lines ... | aconv -v "length=100" -q "length += strlen(line)" -post length -> prints the total length of the input (the sum of the lengths of the input strings) + 100 (initial value) ... | aconv -v "sum" -q "sum += #line" -post sum -> prints the sum of the incoming lines (nonnumber values are evaluated to zero) ... | aconv -a sum -> the same as the previous one, in shorter form ... | aconv "file" "get_file_size(file)" "get_file_mtime(file)" -os " | " -g -> the input files are listed with name,size,mod. time (each file in separate line) ... | aconv -v "size" -q "size = get_file_size(file)" "size" "size / 1024" "size / 1024 / 1024" -g -os "," -> the file sizes are shown in bytes,kbytes,mbytes, respectively (the get_file_size() is evaluated only once for each file)