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 } } { lastPrice[$2] = $4 } END { widestNum = 0 for (tic in lastPrice) { str = sprintf("%.2f", lastPrice[tic]) strLen = length(str) if (strLen > widestNum) { widestNum = strLen } } for (tic in lastPrice) { printf "%-9s : %"widestNum".2f\n", tic, lastPrice[tic] } }