title: How can I escape the vertical bar when doing command line with Ruby?
body: <p>I have this command line input in Windows:</p>
  
  <pre><code>dir /b | ruby -ne 'f=$_.chomp;File.read(f).each_line{|line| print f if line =~ /helloworld/};'
  </code></pre>
  
  <p>This line is to find all files under current directory with <code>helloworld</code> in it. (I understand there are many other ways to do this but the post is not focusing on that)</p>
  
  <p>My question is:</p>
  
  <p>This line gives error saying <code>line is not a valid command</code>. Then I realized <code>|</code> in Ruby as a brace for block variable is a pipe sign in cmd. I tried to change the whole line into double quoted and escape the | sign but no success. How can I escape the vertical bar |?</p>
  
  <p><strong>Please don't answer other ways to do the task such as using other tools like grep, find, sed or awk, or change the block into for loop.</strong></p>