0

I have an expression

ls -l `find . -type f` | tr -s [:space:] | cut -d ' ' -f 5 | sort | uniq -c  | tr -s [:space:] | sort -k 2n 

which creates a 2D array like:

 xx yy
 xx yy
 xx yy

where xx is numerosity of incidence and yy is the size of the files with incidence xx. What i need is to compare every cell yy with some numbers (like if (yy < 100 B) .. if(yy < kiB) .. etc.) and according to this print '#' xx times to the right row in table. I was trying

awk '{print $1;}'

but it just takes one column and I can´t specify row like in C for example.
Is it somehow possible to do it? it must work on dash, ksh and bash.

1 Answer 1

0

Before each block in awk you can put a condition that must be met.

awk '$2 < 100 {for (i = 0; i < $1; i++) printf "#"; next;}
     $2 < 500 {for (i = 0; i < $1; i++) printf "x"; next;}
     ...'
1
  • Thanks, it works, although I must repeatly call the expression but it isn´t such a big problem
    – Erik
    Commented Mar 17, 2017 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .