Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2811

シェルスクリプト(bash) チートシート

$
0
0

パイプライン・リスト

コード意味
パイプラインls -l | less左側のコマンドの標準出力が、右側のコマンドの標準入力に接続される
&&リストtest -f file && file file2左側のコマンドの結果がの場合のみ、右側のコマンドが実行される
||リストtest -f file || exit 1左側のコマンドの結果がの場合のみ、右側のコマンドが実行される

if文

if[条件文1]
then
   処理1
elif[条件文2]
then
   処理2
else
   処理3
fi

case文

case比較元文字列 in
    比較先文字列1)処理1
        ;;比較先文字列2)処理2
        ;;*)処理3
        ;;・・・・(省略可)
esac

for文

値はコマンドもOK 'cat filelist'、カレントディレクトリにあるファイル名は「*」

for 変数名 in 値1 値2 
do
    処理
done

Viewing all articles
Browse latest Browse all 2811

Trending Articles