Skip to content

Instantly share code, notes, and snippets.

@Buravo46
Created June 1, 2017 13:48
Show Gist options
  • Save Buravo46/56e2ce249f6d25715f30ca9c530fcc9e to your computer and use it in GitHub Desktop.
Save Buravo46/56e2ce249f6d25715f30ca9c530fcc9e to your computer and use it in GitHub Desktop.
【Shell】エラー処理
  • $?で判定のパターン
grep -e "hoge" hoge.txt
if [ $? -ne 0 ]; then
  echo "error"
fi
  • 条件文でコマンド実行のパターン
if ls hoge.txt ; then
  echo "found"
else
  echo "not found"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment