title: Not sure how flock works. Need some clarification
body: <p>I have a bash script that makes a cURL request and writes the output to a file called <code>resp.txt</code>.  I need to create an exclusive lock so that I can write to that file and not worry about multiple users running the script and editing the text file at the same time. </p>
  
  <p>Here is the code that I expect to lock the file, perform the request, and write to the text file:</p>
  
  <pre><code>(
  flock -e 200
  curl 'someurl' -H 'someHeader' &gt; resp.txt
  ) 200&gt;/home/user/ITS/resp.txt
  </code></pre>
  
  <p>Is this the correct way to go about this?  My actual script is a bit longer than this, but it seems to break when I add the <code>flock</code> syntax to the bash script.  My understanding is that this creates a subshell that can write to the locked file.  I'm just not sure if I need to add the file descriptor to the curl request like this:</p>
  
  <pre><code>curl 'someurl' -H 'someHeader' 200&gt;resp.txt
  </code></pre>
  
  <p>If someone could explain how these file descriptors work and let me know if I am locking the file correctly that would be awesome!</p>