OS:Mac Mojave 10.14.3
我最近开始自学python,并写了一份命令,该命令在更新软件包后执行,以递归清除" Pycache"文件夹。该命令使用Homebrew的"垃圾"公式。
cd '/Library/Frameworks/python.framework/versions/3.7'
find . -type d -name "__pycache__" -exec trash {} ;
命令效果很好,但是我的问题是在运行时显示输出终端显示。它没有显示要删除的每个目录,而仅显示被跳过的目录,因为它们不包含" Pycache"文件夹。为什么会这样向后输出?
在这里参考是输出的一部分:
find: ./lib/python3.7/site-packages/pip/_vendor/urllib3/util/__pycache__: No such file or directory
find: ./lib/python3.7/site-packages/pip/_vendor/urllib3/__pycache__: No such file or directory
find: ./lib/python3.7/site-packages/pip/_vendor/urllib3/contrib/__pycache__: No such file or directory
find: ./lib/python3.7/site-packages/pip/_vendor/urllib3/packages/__pycache__: No such file or directory
find: ./lib/python3.7/site-packages/pip/_vendor/urllib3/packages/backports/__pycache__: No such file or directory
find: ./lib/python3.7/site-packages/pip/_vendor/urllib3/packages/ssl_match_hostname/__pycache__: No such file or directory
谢谢
trash
默认情况下是无声的。如果您希望它是冗长的,请使用-v
选项:
trash -v
现在看起来像这样的完整命令:
cd '/Library/Frameworks/python.framework/versions/3.7'
find . -type d -name "__pycache__" -exec trash -v {} ;