Shell 脚本:从每个子目录创建 TAR,解引用符号链接

tar_each_directory.sh
for i in ../mydir/*; do
    if [ -L "$i" ]; then
        # Dereference the symlink
        tar cvhf "$(basename "$i").tar" "$i"
    else
        # Regular tar without dereferencing
        tar cvf "$(basename "$i").tar" "$i"
    fi
done

Check out similar posts by category: Linux