title: UNIX Shell: List all files in directory excluding directory names
body: <p>I want to list all the files in a directory recursively. I am storing this output in a file that I will later iterate through and use each line as an argument in another command.</p>
  
  <p>However all the commands I have tried have listed the directory name as one of the output lines followed by the files and directories contained in the directory.</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>tree -if --noreport . &gt; files_names.txt
  </code></pre>
  
  <p>This has given me some success, but it still prints the directories. An example output is as follows:</p>
  
  <pre><code>/testdir
  /testdir/rightfolder/
  /testdir/rightfolder/file2.txt
  /testdir/rightfolder/file3.txt
  /testdir/wrongfolder/
  /testdir/wrongfolder/file.txt
  </code></pre>
  
  <p>I have checked the man pages for tree and ls.</p>
  
  <p>Is there a flag or another command that will give me the correct output. I have considered using a flag for tree to list the directories and then removing all those entries from the original list but this is not elegant at all.</p>