Shell脚本使用命令行参数创建目录

时间:2014-08-11 00:43:59

标签: linux bash unix scripting sh

a)将命令行参数作为:

./myscript.sh <path> dir1 dir2 dir5 dir2/dir5 dir5/dir7

并在

中创建目录
<path>/dir1 <path>/dir2 <path>/dir5 <path>/dir2/dir5 <path>/dir5/dir7

1 个答案:

答案 0 :(得分:1)

#!/bin/bash
for i in "$@"; do
    mkdir -p -- "$i"
done

#!/bin/bash
mkdir -p -- "$@"