title: bash - echo: write error: invalid argument
body: <p>I am new to bash and trying to write a script that disables kworker business as in aMaia's answer <a href="https://stackoverflow.com/questions/21305008/ubuntu-kworker-thread-consumes-100-cpu">here</a>. </p>
  
  <p>So far, I have this, which I run from root:</p>
  
  <pre><code>  1 #!/bin/bash                                                                      
    2                                                                                  
    3 cd /sys/firmware/acpi/interrupts                                                 
    4 for i in gpe[[:digit:]]* # Don't mess with gpe_all                               
    5 do                                                                               
    6     num=`awk '{print $1}' $i`                                                    
    7     if (( $num &gt;= 1000 )); then  # potential CPU hogs?                           
    8         # Back it up and then disable it!!                                       
    9         cp $i /root/${i}.backup                                                  
   10         echo "disable" &gt; $i                                                      
   11     fi                                                                           
   12 done  
  </code></pre>
  
  <p>But running it results in:</p>
  
  <pre><code>./kkiller: line 10: echo: write error: Invalid argument
  </code></pre>
  
  <p>What is going on here? I thought <code>$i</code> was just the file name, which seems like the correct syntax for echo. </p>
  
  <p>Suggestions for cleaning up/improving the script in general are also appreciated! </p>
  
  <p>Update: With <code>set -vx</code> added to the top of the script, here is a problematic iteration:</p>
  
  <pre><code>+ for i in 'gpe[[:digit:]]*'
  awk '{print $1}' $i
  ++ awk '{print $1}' gpe66
  + num=1024908
  + ((  1024908 &gt;= 1000  ))
  + cp gpe66 /root/gpe66.backup
  + echo disable
  ./kkiller: line 10: echo: write error: Invalid argument
  </code></pre>