title: How to search a a directory tree in TCL for files that end in .so or .a and build a list of those directories
body: <p>I'm trying to write a set of TCL scripts that helps setup a user's environment for a set of libraries that are not in their standard <code>LD_LIBRARY_PATH</code> as part of a support solution.</p>
  
  <p>Since the system is rather sparse in terms of what I can install, I don't really have access to any TCL extensions and am trying to do this in base TCL as much as possible. I'm also relatively new to TCL as a language.</p>
  
  <p>What I'd like to do is search through a directory structure and locate the directories that have <code>.so</code> and <code>.a</code> files in them, build a list of those, and, eventually add them to the user's <code>$LD_LIBRARY_PATH</code> variable.</p>
  
  <p>If I were doing this in a shell, I'd just use find with something like this:</p>
  
  <pre><code>find /dir -type f \( -name "*.so" -o -name "*.a" \) | awk -F/ 'sub(FS $NF,x)' | sort -u
  </code></pre>
  
  <p>I could hard-code the paths, but we want a single set of scripts that can manage several different applications.</p>
  
  <p>Any ideas would be very much appreciated.</p>