title: Write to file if header is a 404 using Bash and Curl on Linux
body: <p>I have a simple script that accepts 2 arguments, a URL and a log file location. Theoretically, it should capture the header status code from the curl command and if it is a 404, then append the URL to the log file. Any idea where it is failing?</p>
  
  <pre><code>#!/bin/bash
  CMP='HTTP/1.1 404 Not Found'                                                        # This is the 404 Pattern
  OPT=`curl --config /var/www/html/curl.cnf -s -D - "$1"  -o /dev/null | grep 404`    # Status Response
  if [ $OPT = $CMP ] 
  then
      echo "$1" &gt;&gt; "$2"                                                               # Append URL to File
  fi
  </code></pre>