bash 如何找到环境变量的设置位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8058487/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 01:02:17  来源:igfitidea点击:

How to find where an environment variable is set

bashenvironment-variables

提问by well actually

Say I have some environment variable PROJECT_HOME. I want to find out which file it is set in. How do I do this?

假设我有一些环境变量 PROJECT_HOME。我想知道它设置在哪个文件中。我该怎么做?

采纳答案by chemila

find $HOME -type f -exec grep -Hn 'PROJECT_HOME' {} \;

回答by Andrew Schulman

grep -r PROJECT_HOME /etc $HOME

will probably find it.

可能会找到它。

回答by timo

I like using ack!in these kind of situations. I would change into the likely super directory and do an ack PROJECT_HOME.

我喜欢使用ack!在这种情况下。我会切换到可能的超级目录并执行ack PROJECT_HOME.