From: Andy Spencer Date: Wed, 9 May 2012 05:02:22 +0000 (+0000) Subject: fix awk for head command X-Git-Url: http://pileus.org/git/?p=vpaste;a=commitdiff_plain;h=aeb74290389cee356e958f94e14d429777e274ac fix awk for head command --- diff --git a/index.cgi b/index.cgi index f3a4a7e..e311a94 100755 --- a/index.cgi +++ b/index.cgi @@ -71,14 +71,14 @@ function do_cmd { header text/plain case "$1" in head) - awk ' - BEGIN { rows=4; cols=60; } + awk -v 'rows=4' -v 'cols=60' ' FNR==1 { gsub(/.*\//, "", FILENAME); print FILENAME print "-----" } FNR==1,/^$/ { next } /\S/ { i++; printf "%."cols"s\n", $0 } - i>=rows { i=0; print ""; nextfile } + i>=rows { nextfile } + ENDFILE { i=0; print "" } ' $(ls -t db/*) ;; ls)