1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Shellのエラー処理

Posted at

シンプルに1行でエラー処理ができたのでメモ

下記のような構文を用いる

{エラー判定するコマンド} && {成功時に実行するコマンド} || {エラー時に実行するコマンド}

test 0 -gt 30 && echo 正しい || echo 間違い
処理結果: 間違い
test 100 -gt 30 && echo 正しい || echo 間違い
処理結果: 正しい
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?