由于我经常用 Python 编写代码,所以总是看到 .pyc 文件有点烦人,我想此时隐藏它们。我尝试了以下方法,但我似乎无法弄清楚如何让它在多列中打印。
ceasarbautista@hse140:~/Desktop/Statistics/statistics/probability$ ls
__init__.py calculus.py conditional.py counting.pyc distributions.pyc event.pyc objects.pyc
__init__.pyc calculus.pyc counting.py distributions.py event.py objects.py plots.py
ceasarbautista@hse140:~/Desktop/Statistics/statistics/probability$ ls | grep -v .pyc
__init__.py
calculus.py
conditional.py
counting.py
distributions.py
event.py
objects.py
plots.py
ceasarbautista@hse140:~/Desktop/Statistics/statistics/probability$ ls -C | grep -v .pyc
conditional.py event.py
答案1
你可以这样做:
find . ! -name '*.pyc' -exec ls -dC {} +
或者使用高级 shell:
ksh
:ls -dC !(*.pyc)
zsh
:setopt extendedglob
然后ls -dC ^*.pyc
bash
:shopt -s extglob
然后ls -dC !(*.pyc)
答案2
过滤通过column
.
ls | grep -v '\.pyc$' | column