BEGIN { RS="\n" FS=";" split(ARG_TICKER, _tmp_tickers, ";") for (i in _tmp_tickers) { tickers[_tmp_tickers[i]] = "" hasTickers = 1 } gsub(/[-: ]/, "", ARG_DATE_AFTER); gsub(/[-: ]/, "", ARG_DATE_BEFORE); } (hasTickers == 1) && ($2 in tickers == 0) { next } { fieldDate=$1 gsub(/[-: ]/, "", fieldDate); if (ARG_DATE_AFTER != "" && ARG_DATE_AFTER > fieldDate) { next } if (ARG_DATE_BEFORE != "" && ARG_DATE_BEFORE < fieldDate) { next } } { totalTrans[$2]++ } END { mostTrans = 0 for (tic in totalTrans) { if (mostTrans < totalTrans[tic]) { mostTrans = totalTrans[tic] } } if (ARG_WIDTH < 1) { ARG_WIDTH = 1 } for (tic in totalTrans) { if (ARG_WIDTH == 1) { cols = totalTrans[tic] } else { cols = (totalTrans[tic] / mostTrans) * ARG_WIDTH } row = "" for (i = 1; i <= cols; i++) { row = row"#" } printf "%-9s : %s\n", tic, row } }