title: why this code isn't working in bash?
body: <p>I am using tail -f to fetch log file and output of log this command is input to grep command with search for "ERROR" string and output of grep is used to create/write into a temporary file(<strong>tmpLog</strong>) .</p>
  
  <p><strong>command :</strong></p>
  
  <pre><code>tail -f logfile |  grep -n -i "ERROR" &gt; tmpLog
  </code></pre>
  
  <p><strong>logfile content</strong></p>
  
  <pre><code>100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.003
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.0033
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.004
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.005
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.006
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.007
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.0023
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.0043
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.004
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.005
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.006
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.007
  100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.0043
  </code></pre>
  
  <p>Issue is , i am not getting content in tmpLog file , although it is created but with empty content
  But when i try this</p>
  
  <p>tail -f logfile | grep -n -i "ERROR"  *> tmpLog</p>
  
  <p>i have <strong>content in tmpLog</strong></p>
  
  <pre><code>a.sh:21:    tail -f logfile |  grep -n -i "ERROR" &gt; tmpLog &amp;  #&gt; /dev/null
  logfile:1:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.003
  logfile:2:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.0033
  logfile:3:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.004
  logfile:4:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.005
  logfile:5:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.006
  logfile:6:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.007
  logfile:7:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.0023
  logfile:8:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.0043
  logfile:9:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.004
  logfile:10:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.005
  logfile:11:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.006
  logfile:12:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.007
  logfile:13:100.66.230.2 - - [03/Apr/2017:11:40:23 +0900] "ERROR /favicon.ico HTTP/1.1" 200 26238 0.0043
  </code></pre>
  
  <p>but i am getting this line <strong>a.sh:21:    tail -f logfile |  grep -n -i "ERROR" > tmpLog &amp;  #> /dev/null</strong> over the top of log which i don't want</p>