#!/bin/bash
ls /nonexistentdirectory/
if [ $? -ne 0 ]; then
  echo "error"
else
  echo "ok"
fi


