小编Pin*_*ken的帖子

for 循环遍历带有空格的目录 glob 将不起作用

我正在尝试递归地处理镜像在第二个位置的目录和文件
我定义的函数是:

#!/bin/bash
set -e
shopt -s nullglob
shopt -s dotglob
dom() {
    echo "Dirs:";
    for elem in "$1/*/"; do
        if test -d "$elem"; then
            echo is Dir # Is never called
        fi
        echo "$elem"; # intended to be dom "$elem" "$2"
    done;
    echo "Files:";
    for elem in "$1/*"; do # Same issues as above
        if test -f "$elem"; then
            echo "$elem is File" # is never called
        fi
        echo do stuff with "$elem" "$2/$elem";
    done;
}

dom "$2" "$1"; …
Run Code Online (Sandbox Code Playgroud)

bash wildcards

2
推荐指数
1
解决办法
419
查看次数

标签 统计

bash ×1

wildcards ×1