Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to run through all subdirectories of a given directory?
    text
    copied!<p>I wrote a script that reports on files directly in the present directory. I would like to extend my script so that it runs through all subdirectories and subdirectories of subdirectories and so on and makes an overall report. </p> <p>for example:</p> <p><img src="https://i.stack.imgur.com/tamxo.png" alt="enter image description here"></p> <pre><code>my_script &gt; report </code></pre> <p>creates a report like:</p> <pre><code>HEADERS += \ header1.h \ header2.h \ SOURCES += \ source1.cpp \ source2.cpp \ </code></pre> <p>But let us imagine we have subfolders:</p> <p><img src="https://i.stack.imgur.com/Z0DSG.png" alt="enter image description here"></p> <p>I would like to make a recursive report like:</p> <pre><code>INCLUDEPATH += "relative path to subfolder1" "result of my_script for subfolder1" INCLUDEPATH += "relative path to subfolder2" "result of my_script for subfolder2" HEADERS += \ header1.h \ header2.h \ SOURCES += \ source1.cpp \ source2.cpp \ </code></pre> <p>I tried to look at similar questions but all of them seemed different in nature and were answered by a one line linux command. I think that my problem is more complicated, since the script needs to call itself recursively.</p> <p>EDIT: here is my script:</p> <pre><code>#!/bin/bash if ls *.h &amp;&gt; /dev/null; then echo "HEADERS += \ " printf ' %s \\\n' *.h echo "" fi if ls *.cpp &amp;&gt; /dev/null; then echo "SOURCES += \ " printf ' %s \\\n' *.cpp echo "" fi if ls *.ui &amp;&gt; /dev/null; then echo "FORMS += \ " printf ' %s \\\n' *.ui fi </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload