Iterate over directories and subdirectories recursively showing 'path/file' in ruby
<p>I am using the code below to iterate recursively over files of directories and subfolders:</p>

<pre><code>Dir.glob("**/*").each do |file|

    filename = "#{File.basename(file)}"
    output = `git log -1 -r -n 1 --pretty=format:\"%h: #{filename}\" -- #{filename}`

end
</code></pre>

<p>The result I am getting from this iteration looks like this:</p>

<pre><code>Actual Output:
&lt;The format I choose&gt;: folder1
&lt;The format I choose&gt;: a_file
&lt;The format I choose&gt;: folder2
&lt;The format I choose&gt;: a_file 
&lt;The format I choose&gt;: another_file 
&lt;The format I choose&gt;: folder3
&lt;The format I choose&gt;: a_file
</code></pre>

<p>While the form I want is below.</p>

<pre><code>Expected Output:
    &lt;The format I choose&gt;: folder1/a_file
    &lt;The format I choose&gt;: folder2/a_file
    &lt;The format I choose&gt;: folder2/another_file
    &lt;The format I choose&gt;: folder3/a_file
</code></pre>

<p>Can you point and explain my error in the loop?</p>