title: Find files and execute command
body: <p>I have a lot of rar archives structured in individual folders and would like to script unpacking them all.</p>
  
  <p>I'm having trouble figuring out how it should be done and need some help.</p>
  
  <pre><code>#!/bin/bash
  ## For all inodes
  for i in pwd; do
      ## If it's a directory
      if [ -d "$i" ] then
          cd $i
  
          ## Find ".rar" file
          for [f in *.rar]; do
              ./bin/unrar x "$f" # Run unrar command on filename
              cd ..
          done
      done
  done
  </code></pre>
  
  <p>I am not familiar with bash scripting and I assume the code is wrong more than once. But I guess this should be the basic structure</p>