[Insight-users] bash script to search example files for terms

Darren Weber darren.weber.lists at gmail.com
Mon Oct 12 23:23:54 EDT 2009


On Mon, Oct 12, 2009 at 7:50 PM, Andrew Maclean
<andrew.amaclean at gmail.com>wrote:

> Could this script with appropriate modifications also be added to VTK?
> It strikes me as useful.
>


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

This is an example run on my system (the script attached is suited to my
install paths):

$ vtkSearchExamples.bash 'vtkIdentityTransform' 'vtkImageClip'

Search term: vtkIdentityTransform
Searching VTK files in: /opt/local/share/vtk/examples
Searching VTK files in: /opt/local/share/vtk/testing
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/TransformPolyData.tcl

Search term: vtkImageClip
Searching VTK files in: /opt/local/share/vtk/examples
/opt/local/share/vtk/examples/ImageProcessing/Tcl/HistogramWidget.tcl
Searching VTK files in: /opt/local/share/vtk/testing
/opt/local/share/vtk/testing/VolumeRendering/Testing/Cxx/TestMinIntensityRendering.cxx
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/contour2DAll.tcl
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/contour3DAll.tcl
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/imageMCAll.tcl
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/sync3dAll.tcl
/opt/local/share/vtk/testing/Graphics/Testing/Tcl/testDataSetTriangleFilter.tcl
/opt/local/share/vtk/testing/Imaging/Testing/Tcl/TestAccumulate.tcl
/opt/local/share/vtk/testing/Imaging/Testing/Tcl/TestGradientMagnitude2.tcl
/opt/local/share/vtk/testing/Imaging/Testing/Tcl/TestSkeleton2D.tcl
/opt/local/share/vtk/testing/Parallel/Testing/Tcl/TestBranchExtentTranslator.tcl



#######BEGIN SCRIPT
#!/bin/bash

if [ $# -lt 1 ]; then
    echo "$0 'search term' ['search term' ...]"
    exit 1
fi

vtkExamplePath="/opt/local/share/vtk/examples"
vtkTestingPath="/opt/local/share/vtk/testing"

for term in $@; do
    echo
    echo "Search term: ${term}"
    for vtkPath in "${vtkExamplePath}" "${vtkTestingPath}" ; do
        if [ ! -d ${vtkPath} ]; then
            echo "Path not found: ${vtkPath}"
        fi
        echo "Searching VTK files in: ${vtkPath}"
        cxxFiles=$(find ${vtkPath} -name "*.cxx")
        grep -l -E -e ${term} ${cxxFiles}
        tclFiles=$(find ${vtkPath} -name "*.tcl")
        grep -l -E -e ${term} ${tclFiles}
        pyFiles=$(find ${vtkPath} -name "*.py")
        grep -l -E -e ${term} ${pyFiles}
    done
done
#######END SCRIPT


Again, feel free to incorporate this into the VTK cvs, with suitable
open-source license that's compatible with vtk.

Take care,
Darren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091012/8ffce778/attachment.htm>


More information about the Insight-users mailing list