title: Finding executable files using ls and grep
body: <p>I have to write a script that finds all executable files in a directory. So I tried several ways to implement it and they actually work. But I wonder if there is a nicer way to do so.</p>
  
  <p>So this was my first approach:</p>
  
  <pre><code>ls -Fla | grep \*$
  </code></pre>
  
  <p>This works fine, because the -F flag does the work for me and adds to each executable file an asterisk, but let's say I don't like the asterisk sign.</p>
  
  <p>So this was the second approach:</p>
  
  <pre><code>ls -la | grep -E ^-.{2}x 
  </code></pre>
  
  <p>This too works fine, I want a dash as first character, then I'm not interested in the next two characters and the fourth character must be a x.</p>
  
  <p>But there's a bit of ambiguity in the requirements, because I don't know whether I have to check for user, group or other executable permission. So this would work:</p>
  
  <pre><code>ls -la | grep -E ^-.{2}x\|^-.{5}x\|^-.{8}x
  </code></pre>
  
  <p>So I'm testing the fourth, seventh and tenth character to be a x. </p>
  
  <p>Now my real question, is there a better solution using ls and grep with regex to say:</p>
  
  <p>I want to grep only those files, having at least one x in the ten first characters of a line produced by <code>ls -la</code></p>