title: Parse Json file in HDFS and write to output only if key is available
body: <p>I have a JSON file with &quot;name&quot; as key and &quot;url&quot; as another key. Not all records in the JSON have the &quot;url&quot; key. So when I am trying to write to text it gets written as null. So, I will have to do a check if url key is present and if present, then it has to be written to 2 output text files. name will goto name.txt and url will goto url.txt</p>
  <pre><code>{ [ {&quot;name&quot;: &quot;a&quot;, url: &quot;url1&quot;}, {&quot;name&quot;: &quot;b&quot;}, {&quot;name&quot;: &quot;C&quot;} ] }
  </code></pre>
  <p>Expected output:</p>
  <pre><code>name.txt
  a
  url.txt
  url
  </code></pre>
  <p>What i tried so far:</p>
  <pre><code>name=`hdfs dfs -cat $path | jq -r '.name'`
  url=`hdfs dfs -cat $path | jq -r '.name'`
  
  echo ${name} &gt;&gt; name.txt
  echo ${url} &gt;&gt; url.txt
  </code></pre>
  <p>The problem with above is if url is not found it writes a null to output file and equivalent name is written to name.txt file.</p>
  <p>How to skip the records from writing to output file when url json tag is not found</p>