文件丢失echo
但存在ls -a
。为什么?
bojan@hyperion:~$ touch .ignoramus
bojan@localhost:~$ ls -al | grep ignor
-rw-rw-r-- 1 bojan bojan 0 Apr 19 19:05 .ignoramus
bojan@localhost:~$ GLOBIGNORE=".ignoramus";
bojan@localhost:~$ echo .i*
.icons
bojan@localhost:~$ ls -al | grep ignor
-rw-rw-r-- 1 bojan bojan 0 Apr 19 19:05 .ignoramus
bojan@localhost:~$ echo $GLOBIGNORE
.ignoramus
Run Code Online (Sandbox Code Playgroud)
ls man 说-a
只显示隐藏,没有提到 GLOBIGNORE。
-a, --all
do not ignore entries starting with .
ls (GNU coreutils) 8.23
GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
Run Code Online (Sandbox Code Playgroud)
设置GLOBIGNORE
对 没有影响ls
,ls
说明书也没有提到GLOBIGNORE
,因为ls
不关心GLOBIGNORE
。它只是 bash 的一个特性,这使得它在 glob 模式中省略了一些文件。
使用echo .i*
, bash 列出文件,因此GLOBIGNORE
开始。使用ls -a
,ls
列出文件,因此GLOBIGNORE
无关紧要。
GNUls
有一个类似的特性:你可以传递一个模式作为命令行选项来忽略。
ls -a -I .ignoramus
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
730 次 |
最近记录: |