仅限于 MacOS, linux 下面路径不太一样, 自行调整
shell 函数 添加到 ~/.zshrc
或者 ~/.bashrc
即可 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 findJars () { jar_name=$1 rmJar=$2 set -x if [[ -z $jar_name ]]; then echo "Usage: $0 jar_name rm" set +x exit 0 else array=("$HOME /.m2/repository" "$HOME /.ivy2/cache" "$HOME /Library/Caches/Coursier" ) for i in ${array[@]} ; do if [[ -z $rmJar ]]; then find $i -name "$jar_name " else find $i -name "$jar_name " | xargs rm -rf fi done fi set +x }
查找 hive 相关 jar 包 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ❯ findJars "*hive-exec*" +findJars:4> [[ -z '*hive-exec*' ]] +findJars:9> array=( /Users/iitii/.m2/repository /Users/iitii/.ivy2/cache /Users/iitii/Library/Caches/Coursier ) +findJars:10> i=/Users/iitii/.m2/repository +findJars:11> [[ -z '' ]] +findJars:12> find /Users/iitii/.m2/repository -name '*hive-exec*' +findJars:10> i=/Users/iitii/.ivy2/cache +findJars:11> [[ -z '' ]] +findJars:12> find /Users/iitii/.ivy2/cache -name '*hive-exec*' +findJars:10> i=/Users/iitii/Library/Caches/Coursier +findJars:11> [[ -z '' ]] +findJars:12> find /Users/iitii/Library/Caches/Coursier -name '*hive-exec*' /Users/iitii/Library/Caches/Coursier/v1/https/maven.aliyun.com/nexus/content/groups/public/org/apache/hive/hive-exec /Users/iitii/Library/Caches/Coursier/v1/https/maven.aliyun.com/nexus/content/groups/public/org/apache/hive/hive-exec/2.3.9/.hive-exec-2.3.9.pom.sha1.checked /Users/iitii/Library/Caches/Coursier/v1/https/maven.aliyun.com/nexus/content/groups/public/org/apache/hive/hive-exec/2.3.9/hive-exec-2.3.9.jar +findJars:18> set +x
删除 hive 相关 jar 包 最后这个 d 其实填什么都可以, 只要填了, 就会删除. 慎用…