<br>Hi Andrew,<br><br>This version below uses 'grep' options to replace the 'find' utility; the grep options provide a case-insensitive search (-i) and recursion through directories (-r), with an include pattern to identify file types (.cxx, .tcl, .py).  The script now has a 'continue' statement if the vtkPath doesn't exist.  (I don't have commit rights to the cvs.)<br>
<br><br>#####BEGIN SCRIPT<br><span style="font-family: courier new,monospace;">#!/bin/bash</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">if [ $# -lt 1 ]; then</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    echo "$0 'search term' ['search term' ...]"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    exit 1</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">fi</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">vtkExamplePath="/opt/local/share/vtk/examples"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">vtkTestingPath="/opt/local/share/vtk/testing"</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">for term in $@; do</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    echo</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    echo "Search term: ${term}"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    for vtkPath in "${vtkExamplePath}" "${vtkTestingPath}" ; do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        if [ ! -d ${vtkPath} ]; then</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">            echo "Path not found: ${vtkPath}"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">            continue</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        fi</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        echo "Searching VTK files in: ${vtkPath}"</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        grep -l -E -i -r --include='*.cxx' --regexp=${term} ${vtkPath}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        grep -l -E -i -r --include='*.tcl' --regexp=${term} ${vtkPath}</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        grep -l -E -i -r --include='*.py'  --regexp=${term} ${vtkPath}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    done</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">done</span><br>#####END SCRIPT<br>
<br><br>This is an example run on my OSX-MacPorts system (I maintain the vtk-devel port in MacPorts, currently at ver 5.4.2):<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">$ vtkSearchExamples.bash 'vtkIdentityTransform' 'vtkImageClip'</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Search term: vtkIdentityTransform</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Searching VTK files in: /opt/local/share/vtk/examples</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">Searching VTK files in: /opt/local/share/vtk/testing</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Graphics/Testing/Tcl/TransformPolyData.tcl</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Search term: vtkImageClip</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Searching VTK files in: /opt/local/share/vtk/examples</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">/opt/local/share/vtk/examples/ImageProcessing/Tcl/HistogramWidget.tcl</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Searching VTK files in: /opt/local/share/vtk/testing</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/VolumeRendering/Testing/Cxx/TestMinIntensityRendering.cxx</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Graphics/Testing/Tcl/contour2DAll.tcl</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Graphics/Testing/Tcl/contour3DAll.tcl</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Graphics/Testing/Tcl/imageMCAll.tcl</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Graphics/Testing/Tcl/sync3dAll.tcl</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Graphics/Testing/Tcl/testDataSetTriangleFilter.tcl</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Imaging/Testing/Tcl/TestAccumulate.tcl</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Imaging/Testing/Tcl/TestGradientMagnitude2.tcl</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Imaging/Testing/Tcl/TestSkeleton2D.tcl</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">/opt/local/share/vtk/testing/Parallel/Testing/Tcl/TestBranchExtentTranslator.tcl</span><br>
<br><br><br><br>Regards,<br>Darren<br><br><br><br><br><br><br><div class="gmail_quote">On Mon, Oct 12, 2009 at 10:23 PM, Andrew Maclean <span dir="ltr"><<a href="mailto:a.maclean@cas.edu.au">a.maclean@cas.edu.au</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">








<div link="blue" vlink="purple" lang="EN-AU">

<div>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Hi Darren,</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">  It is in VTK/Examples.</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">   I modified the script slightly.</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">Regards</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);">   Andrew</span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<p class="MsoNormal"><span style="font-size: 11pt; color: rgb(31, 73, 125);"> </span></p>

<div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0cm 0cm;">

<p class="MsoNormal"><b><span style="font-size: 10pt;" lang="EN-US">From:</span></b><span style="font-size: 10pt;" lang="EN-US"> Darren Weber
[mailto:<a href="mailto:darren.weber.lists@gmail.com" target="_blank">darren.weber.lists@gmail.com</a>] <br>
<b>Sent:</b> Tuesday, 13 October 2009 14:24<br>
<b>To:</b> <a href="mailto:a.maclean@cas.edu.au" target="_blank">a.maclean@cas.edu.au</a><br>
<b>Cc:</b> Luis Ibanez; VTK Developers; ITK Users<br>
<b>Subject:</b> Re: [Insight-users] bash script to search example files for
terms</span></p>

</div><div><div></div><div class="h5">

<p class="MsoNormal"> </p>

<p class="MsoNormal" style="margin-bottom: 12pt;"> </p>

<div>

<p class="MsoNormal">On Mon, Oct 12, 2009 at 7:50 PM, Andrew Maclean <<a href="mailto:andrew.amaclean@gmail.com" target="_blank">andrew.amaclean@gmail.com</a>>
wrote:</p>

<p class="MsoNormal">Could this script with appropriate modifications also be
added to VTK?<br>
It strikes me as useful.</p>

<div>

<p class="MsoNormal" style="margin-bottom: 12pt;"><br>
<br>
Sure, that's just a change to the search paths (and a slight hack with 'find'
to get all the files, which might be a better solution in the itk version too;
see the script details below).  Note that the file attribute on the script
file is executable and I keep the script below in
${HOME}/bin/vtkSearchExamples.bash<br>
<br>
This is an example run on my system (the script attached is suited to my
install paths):<br>
<br>
<span style="font-family: "Courier New";">$ vtkSearchExamples.bash
'vtkIdentityTransform' 'vtkImageClip'<br>
<br>
Search term: vtkIdentityTransform<br>
Searching VTK files in: /opt/local/share/vtk/examples<br>
Searching VTK files in: /opt/local/share/vtk/testing<br>
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/TransformPolyData.tcl<br>
<br>
Search term: vtkImageClip<br>
Searching VTK files in: /opt/local/share/vtk/examples<br>
/opt/local/share/vtk/examples/ImageProcessing/Tcl/HistogramWidget.tcl<br>
Searching VTK files in: /opt/local/share/vtk/testing<br>
/opt/local/share/vtk/testing/VolumeRendering/Testing/Cxx/TestMinIntensityRendering.cxx<br>
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/contour2DAll.tcl<br>
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/contour3DAll.tcl<br>
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/imageMCAll.tcl<br>
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/sync3dAll.tcl<br>
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/testDataSetTriangleFilter.tcl<br>
/opt/local/share/vtk/testing/Imaging/Testing/Tcl/TestAccumulate.tcl<br>
/opt/local/share/vtk/testing/Imaging/Testing/Tcl/TestGradientMagnitude2.tcl<br>
/opt/local/share/vtk/testing/Imaging/Testing/Tcl/TestSkeleton2D.tcl<br>
/opt/local/share/vtk/testing/Parallel/Testing/Tcl/TestBranchExtentTranslator.tcl<br>
</span><br>
<br>
</p>

</div>

</div>

<p class="MsoNormal" style="margin-bottom: 12pt;">#######BEGIN SCRIPT<br>
<span style="font-family: "Courier New";">#!/bin/bash<br>
<br>
if [ $# -lt 1 ]; then<br>
    echo "$0 'search term' ['search term' ...]"<br>
    exit 1<br>
fi<br>
<br>
vtkExamplePath="/opt/local/share/vtk/examples"<br>
vtkTestingPath="/opt/local/share/vtk/testing"<br>
<br>
for term in $@; do<br>
    echo<br>
    echo "Search term: ${term}"<br>
    for vtkPath in "${vtkExamplePath}"
"${vtkTestingPath}" ; do<br>
        if [ ! -d ${vtkPath} ]; then<br>
            echo
"Path not found: ${vtkPath}"<br>
        fi<br>
        echo "Searching VTK files in:
${vtkPath}"<br>
        cxxFiles=$(find ${vtkPath} -name
"*.cxx")<br>
        grep -l -E -e ${term} ${cxxFiles}<br>
        tclFiles=$(find ${vtkPath} -name
"*.tcl")<br>
        grep -l -E -e ${term} ${tclFiles}<br>
        pyFiles=$(find ${vtkPath} -name
"*.py")<br>
        grep -l -E -e ${term} ${pyFiles}<br>
    done<br>
done</span><br>
#######END SCRIPT<br>
<br>
<br>
Again, feel free to incorporate this into the VTK cvs, with suitable
open-source license that's compatible with vtk.<br>
<br>
Take care,<br>
Darren<br>
<br>
</p>

</div></div></div>

</div>


</blockquote></div><br>