What follows is some fussing with prototype functions, to show how a 'nocomment' can harvest some stats.
The question: what's the longest config file in '/etc' that's nothing but comments, as well as the longest file with no comments? On 10/10/06 I'd written: > nocomment() { grep -v -e '^#.*$\|^$' $1 ; } > > ...but allow for other whitespace, and take stdio. I didn't notice, but that function also accepts standard input. This 2nd version will remove whitespace-only lines as well as blank lines: nocomment() { grep -v -e '^#.*$\|^[[:space:]]*$' $1 ; } Putting it to use. Just cut n' paste the following indented block to an xterm... nocomment () { grep -v -e '^#.*$\|^[[:space:]]*$' $1 } # show number of lines in a file before and after 'nocomment' # NB: the 'grep ""' below might look useless but it catches final lines # that have no linefeeds. # echo -n "hello" | wc -l # one text line # 0 # not what we want # echo -n "hello" | grep "" | wc -l # 1 # OK # There must be a better way... b4after () { grep "" <$1 | wc -l; nocomment $1 | wc -l } # print multiple lines on one line. oneline () { tr '\n' ' ' ; echo } # show percent of a file that's comments and blanks. showpercent () { [ -f $1 -a -r $1 ] && b4after $1 | oneline | while read a b; do [ $a = 0 ] && break; [ $a = $b ] && c=100 || c=$(( $b * 100 / $a )); echo $c $1; done } # show top 10 files in /etc that have the least stuff... for f in /etc/* ; do showpercent $f ; done | sort -g | head ...stop cutting here. Output from my system: 0 /etc/abcde.conf 0 /etc/bootparams 0 /etc/conf.modules.old 0 /etc/csh.logout 0 /etc/debfoster.conf 0 /etc/devscripts.conf 0 /etc/dhclient.conf 0 /etc/dnsmasq.conf.dpkg-dist 0 /etc/exports 0 /etc/gateways ...yet those aren't a true 'top ten' as we don't know which has the most commented lines. That loop can be used in a pipe to find out: # show my system's top ten 100% comment config files, by number of lines. for f in /etc/* ; do showpercent $f ; done | sort -g | grep -e '^0 .*$' | sed 's/^0 //' | xargs wc -l | head -n -1 | sort -g | tail 49 /etc/dhclient.conf 65 /etc/login.access 71 /etc/serial.conf.dpkg-old 124 /etc/debfoster.conf 137 /etc/hdparm.conf.dpkg-dist 137 /etc/smartd.conf 356 /etc/abcde.conf 363 /etc/devscripts.conf 365 /etc/lpd.conf 415 /etc/dnsmasq.conf.dpkg-dist The template for 'dsnmasq.conf' has the most. Now the same thing but for files in '/etc' with neither comments or blank lines: for f in /etc/* ; do showpercent $f ; done | sort -g | grep -e '^100 .*$' | sed 's/^100 //' | xargs wc -l | head -n -1 | sort -g | tail 43 /etc/group.OLD 49 /etc/passwd 59 /etc/group.org 64 /etc/rarfiles.lst 65 /etc/group 68 /etc/surfraw_elvi.list 113 /etc/therc 150 /etc/mime-magic.dat 271 /etc/oglerc 849 /etc/mime-magic Most of those aren't regular config files; 'oglerc' is an .XML config. I'm thinking the 'showpercent' function would make a useful switch for a 'nocomment' util. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]