Tag: Bash
$0 | コマンド名 |
$1 | 1つ目の引数 |
$2 | 2つ目の引数 |
$* | 残りの引数全部 |
$# | 引数の個数 |
a="XYZ" echo "$a" echo "${a}"
LANG="hoge"
var="a b c" str=${var:-"d e f"} echo $str str=${var2:-"d e f"} echo $str
if [ str="a b c d e" if [ "$str" = "a b c" -o "$str" = "a b c d" ]; then echo ok else echo ng fi
function test() { str=$1 echo "$str" } test a
argv=("$@")
calling_function() { variable="a" array=( "x", "y", "z" ) called_function "${variable}" "${array[@]}" } called_function() { local_variable="${1}" shift local_array=("${@}") }
#!/usr/bin/env bash if [ "$@" != "" ];then echo "$@" else echo empty fi
"$1" "$2" "$3"