LoginSignup
3
4

More than 5 years have passed since last update.

bash覚書

Last updated at Posted at 2015-07-22

自分用のメモ。

if

testコマンドと組み合わせる。
testコマンドは[ 1 -eq 1 ]とも書ける。ただし、空白忘れるとエラーになるので注意。

数値

オプション 使用例 数式
-eq test num1 -eq num2 num1=num2
-ne test num1 -ne num2 num1≠num2
-lt test num1 -lt num2 num1<num2
-le test num1 -le num2 num1≦num2
-gt test num1 -gt num2 num1>num2
-ge test num1 -ge num2 num1≧num2

例) 数値の比較

if test 1 -eq 1; then
 echo true
else
 echo false
fi

文字列

=!=

例) 文字列の比較

if test "hoge" = "hoge"; then
 echo true
else
 echo false
fi

scp

scp -i ~/.ssh/secret.pem -r user@host:hoge /local/path

秘密key使う時は-i

ディレクトリの時は-r

ああ、以下にいろんな事が詳しく書いてあった。
http://bi.biopapyrus.net/linux/bash.html

3
4
0

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
3
4