0

GLOBIGNORE变量的意义

 3 years ago
source link: https://www.lujun9972.win/blog/2017/06/04/globignore%E5%8F%98%E9%87%8F%E7%9A%84%E6%84%8F%E4%B9%89/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

GLOBIGNORE变量的意义

关于GLOBIGNORE的意义可以通过查看bash的man手册来看到:

A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion.
If a filename matched by a pathname expansion pattern also matches one of the patterns in GLOBIGNORE, it is removed from the list of matches.

它可以用来防止误删除某些文件.

比如,假设我们希望谨慎地删除那些隐藏文件,那么我们可以这样设置

GLOBIGNORE=.*

这样一来,用 rm * 就不会删除这些隐藏文件了, 你甚至不能用任何通配符的方式来删除这些隐藏文件,唯一能删除这些文件的方法只能是明确地输入完整的名字.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK