如何cd进入多个目录?

rai*_*r11 3 bash

我不确定我是否问对了,但这里是脚本:

#!/bin/sh
# foundation-setup.sh --- Gets the latest Zurb Foundation release
if test $1
then  
    mkdir $* 
    cd $* 
    wget -q http://foundation.zurb.com/cdn/releases/foundation-latest.zip
    unzip -q foundation-latest.zip
    rm foundation-latest.zip
else     
       echo 'Missing directory Argument!'
fi
Run Code Online (Sandbox Code Playgroud)

当我用 运行它时./foundation-setup.sh a b c,它可以工作,但它只解压缩到第一个目录参数。我认为这与cd $* . 顺便说一下,我是 Linux 和 Bash 的新手。

Ant*_*hon 5

如果要在三个目录中的每一个中提取下载的 zip,脚本的中间部分应该是:

mkdir -- "$@" || exit 
wget -q http://foundation.zurb.com/cdn/releases/foundation-latest.zip &&
  for d do
     (
       cd -- "$d" &&
         unzip -q ../foundation-latest.zip
     )
  done &&
  rm foundation-latest.zip
Run Code Online (Sandbox Code Playgroud)