<br>Hi Luis,<br><br>Please feel free to distribute it with the LGPL license (or a BSD license, or something that is compatible with the ITK license and general OSI principles).<br><br>For a more portable solution, the itk*Path variables might be obtained automatically (how?). The search path could be an input parameter (but that almost defeats the convenience of this bash wrapper around a grep process).<br>
<br>The grep command options list the files where the search term is found (not the lines of those files where the search term occurs). For a bit more value, it's possible to modify the script so that the entire grep loop returns an array of file paths, which could be piped into something like:<br>
<span style="font-family: courier new,monospace;">less -p ${searchTerm} ${fileArray}[@]</span><br style="font-family: courier new,monospace;">Then less would provide the means to page through the files.<br><br>Here is another variation on the same thing - this one searches the testing path and it includes the .tcl and .py example files in the search. It might be called 'itkSearchFiles.bash' ?<br>
<br>###### BEGIN SCRIPT<br>#!/bin/bash<br><br>if [ $# -lt 1 ]; then<br> echo "$0 'search term' ['search term' ...]"<br> exit 1<br>fi<br><br>itkExamplePath="/opt/local/share/InsightToolkit/examples"<br>
itkTestingPath="/opt/local/share/InsightToolkit/testing/Code"<br><br>for term in $@; do<br> echo<br> echo "Search term: ${term}"<br> for itkPath in "${itkExamplePath}" "${itkTestingPath}" ; do<br>
if [ ! -d ${itkPath} ]; then<br> echo "Path not found: ${itkPath}"<br> fi<br> echo "Searching ITK files in: ${itkPath}"<br> grep -l -E -e ${term} ${itkPath}/*/*.cxx<br>
grep -l -E -e ${term} ${itkPath}/*/*.tcl<br> grep -l -E -e ${term} ${itkPath}/*/*.py<br> done<br>done<br>###### END SCRIPT<br>
<br><br>Take care,<br>Darren<br><br><br><br><br><br><br><div class="gmail_quote">On Mon, Oct 12, 2009 at 12:26 PM, Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</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;">Hi Darren,<br>
<br>
This is really useful !<br>
<br>
Thank you for sharing it.<br>
<br>
Do you see any reason for not adding this to the CVS<br>
repository and distribute it along with ITK ?<br>
<br>
Please let us know,<br>
<br>
<br>
Thanks<br>
<br>
<br>
Luis<br>
<br>
<br>
---------------------------------------<br>
<div><div></div><div class="h5">On Mon, Oct 12, 2009 at 2:15 PM, Darren Weber<br>
<<a href="mailto:darren.weber.lists@gmail.com">darren.weber.lists@gmail.com</a>> wrote:<br>
><br>
> This is a short bash script (grep does the work) to search for terms in the<br>
> InsightToolkit example files. It's a convenience wrapper that stores the<br>
> path to the example files (.cxx in this case), the syntax of the grep call,<br>
> and allows multiple terms to be given at once. Modify the example search<br>
> path for your purposes (it could be modified to search for the tcl or python<br>
> examples too). Modify the grep call as you like.<br>
><br>
> #### BEGIN SCRIPT<br>
> #!/bin/bash<br>
><br>
> if [ $# -lt 1 ]; then<br>
> echo "$0 'search term' ['search term' ...]"<br>
> exit 1<br>
> fi<br>
><br>
> # Search the CXX files<br>
> itkExamplePath="/opt/local/share/InsightToolkit/examples/*/*.cxx"<br>
> echo "Searching ITK .cxx files in: ${itkExamplePath}"<br>
><br>
> for term in $@; do<br>
> echo<br>
> echo "Search term: ${term}"<br>
> grep -l -E -e ${term} ${itkExamplePath}<br>
> done<br>
> #### END SCRIPT<br>
><br>
> This is an example call on my platform:<br>
><br>
> $ itkSearchExamples.bash 'TransformWriter' 'TransformReader'<br>
> Searching ITK .cxx files in:<br>
> /opt/local/share/InsightToolkit/examples/*/*.cxx<br>
><br>
> Search term: TransformWriter<br>
> /opt/local/share/InsightToolkit/examples/IO/TransformReadWrite.cxx<br>
><br>
> Search term: TransformReader<br>
> /opt/local/share/InsightToolkit/examples/IO/TransformReadWrite.cxx<br>
> /opt/local/share/InsightToolkit/examples/Registration/DeformableRegistration14.cxx<br>
> /opt/local/share/InsightToolkit/examples/Registration/DeformableRegistration8.cxx<br>
><br>
> Take care,<br>
> Darren<br>
><br>
><br>
</div></div>> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</blockquote></div><br>