title: What does '$?' mean in bash scripts?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7383144/what-does-give-us-exactly-in-a-shell-script">What does &ldquo;$?&rdquo; give us exactly in a shell script?</a>  </p>
  </blockquote>
  
  
  
  <p>What does <code>$?</code> mean in a bash script? Example below:</p>
  
  <pre><code>#!/bin/bash
  # userlist.sh
  
  PASSWORD_FILE=/etc/passwd
  n=1           # User number
  
  for name in $(awk 'BEGIN{FS=":"}{print $1}' &lt; "$PASSWORD_FILE" )
  
  do
    echo "USER #$n = $name"
    let "n += 1"
  done
  
  exit $?
  </code></pre>