Hello,
Tired to use thinks like “awk ‘print $2’” ?
I have done a very litle tool in one ruby script which can make some
filter action with ruby code. Here the help :
===
Usage:
cat ddd | rfilter ‘expression’
or
rfilter ‘expression’ *.c
With
expression = sum(arg)|mult(arg)|toa(arg)|toai(arg)|
toh(a,b)|sela {}|sell {}
arg can be : _0 (all line), _1 (first word), _2 … or any ruby
data
_n words are result of splitting each line with /\s+/
At the end , current result is printed, if exist
Example:
select input with condition and do summation:
du . | rfilter ‘sell {_1.to_i>1000}’ | rfilter ‘sum _1’
LOC count:
ls .rb | xargs -i cat {} | rfilter 'sell {_0!=/^\s#/ && _0.size>0}’
| rfilter ‘sum 1’
Special filter:
cut(fields_number) : print stdin, as array, only indexed fields :
>du . | rfilter ‘cut 1,0’ # invers order : dir, size
I don’t know if think like that already exist, and if it can interest
someone…