There is a tradition of using metasyntactic variables in computer science.

The time has finally come; my alma mater is shutting down my student account to reclaim space, so I pulled all my files off today. As I was watching the scp output scroll by, I realized, "I have a LOT of files names 'foo'."

Then I started to wonder; just how many files do I have? My inexact counting came up with 10 before I realized there must be a way to ask the system itself.

So, enter foo.sh:

find . -iname foo.\* |
  sed -n  's/^.\+\/\([^\/]\+\)$/\1/p' |
  awk '{count[$1]++} END { for (j in count) print j": "count[j]; }'

Which conveniently answers the question for me:

foo.sh: 1
Foo.java: 1
foo.c: 6
foo.txt: 2
foo.h: 1
foo.s: 1
Foo.class: 1
foo.c,v: 1
foo.cpp: 11

21! 21 source files named foo. Ah ah ah ah


No comments:

Post a Comment