title: Bash: Conditional Statement Without IF via Grouping Commands and Boolean Operators
body: <p>I'm trying to eliminate the "if" syntax from my Bash Scripting:</p>
  
  <pre><code>N=
  MD='title|1.md' 
  </code></pre>
  
  <p>This works as expected (prints "1" and "title_1"):</p>
  
  <pre><code>if [ $(echo "$MD" | grep '|') ]; then N="${MD#*|}"; ID=${MD%|*}'_'$N; fi
  echo "$N" ; echo "$ID" 
  </code></pre>
  
  <p>This does not (prints empty):</p>
  
  <pre><code>[[ $(echo $MD | grep '|') ]] &amp;&amp; $(N="${MD#*|}" ; ID=${MD%|*}'_'$N)
  echo "$N" ; echo "$ID" 
  </code></pre>
  
  <p>Running the script with <code>bash +x</code> it returns:</p>
  
  <pre><code>+ N=
  ++ echo 'title|1'
  ++ grep '|'
  + [[ -n title|1 ]]
  ++ N=1
  ++ ID=title_1
  + echo ''
  
  + echo ''
  
  + exit
  </code></pre>
  
  <p>Does anyone can tell me what I'm doing wrong? Thanks.</p>