bashスクリプトは最後のパス変数を選択します

bashスクリプトは最後のパス変数を選択します

私は最初のbashスクリプトを書いています。 GitHubにすべてのリポジトリをインストールしています。

warpInLocations=("[email protected]:acc/toolkit.git" "[email protected]:acc/sms.git" "[email protected]:acc/boogle.git" "[email protected]:acc/cairo.git")

私が設置した時の様子です。

echo "warping in toolkit, sms, boogle and cairo"
for repo in "${warpInLocations[@]}"
do
  warpInDir=$(echo ${warpToLocation}${repo} | cut -d'.' -f1)
  if [ -d "$warpToLocation"]; then
    echo "somethings in the way.. $warpInDir all ready exists"
  else
    git clone $repo $warpInDir
  fi

done

ここでこの行はTwistの位置の前後にorsotoolkitというフォルダを提供したいのですが選択中です。それはおそらくこれが後であるからです。sms/.git@github.

リポジトリに名前を選択させるにはどうすればよいですか?

ベストアンサー1

dir=$(basename [email protected]:acc/toolkit.git .git)

$dirに設定されますtoolkit

コマンドも便利ですdirname

おすすめ記事