有件事我还不是很明白:
touch a b c ; mkdir -p git ; mkdir -p iii/ooo/ppp ; touch git/rtdsfgsdg ; touch .sdfsadf
那么,这是否产生了我想要的结果?
» tree -a
.
├── a
├── b
├── c
├── git
│ └── rtdsfgsdg
├── iii
│ └── ooo
│ └── ppp
└── .sdfsadf
4 directories, 5 files
是的。一些文件,一个目录,以及一个隐藏文件。都很好。
现在我想要删除所有东西,但是我想要保留隐藏文件和git
目录。 GLOBIGNORE
来拯救!
GLOBIGNORE=git rm -rf *
它进行得如何?
» tree -a
.
└── .sdfsadf
0 directories, 1 file
太糟糕了。我的git
文件夹在哪里?为什么GLOBIGNORE
不能按照广告所说的工作?
GLOBIGNORE
A colon-separated list of patterns defining the set of file
names to be ignored by pathname expansion. If a file name
matched by a pathname expansion pattern also matches one of the
patterns in GLOBIGNORE, it is removed from the list of matches.
我正在使用:
» bash --version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
var = old; var = new echo"$ var"
打印old
而不是new
?”本质上相同的答案;但是它们很难通过搜索关键字找到。 - Charles Duffy