Created
March 11, 2024 23:41
-
-
Save hnakamur/89d98c6cfdcc855995b26da725f5f734 to your computer and use it in GitHub Desktop.
bash-args-array.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# コマンドライン引数を配列に格納 | |
args=("$@") | |
# 配列の要素を表示 | |
for arg in "${args[@]}"; do | |
echo $arg | |
done | |
# 特定の要素にアクセス | |
echo "最初の引数: ${args[0]}" | |
echo "二番目の引数: ${args[1]}" |
Author
hnakamur
commented
Mar 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment