UNIX,获取环境变量 [英] UNIX, get environment variable

查看:143
本文介绍了UNIX,获取环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于一个荒唐的问题,我有一个荒唐的问题.

I have a ridiculous question due to a ridiculous problem.

通常,如果我想在UNIX shell中获取环境变量的内容,则可以

Normally if I want to get the contents of an environment variable in UNIX shell, I can do

echo ${VAR}

由于我可笑的情况,让我们假设这是不可能的.

Let's assume, due to my ridiculous situation, that this isn't possible.

如何在没有人看命令本身(而不是输出)的情况​​下,将环境变量的内容发送到stdout,请参阅环境变量的值.

How do I get the contents of an environment variable to stdout, without someone who is looking at the command itself (not the output), see the value of the environment variable.

我可以将解决方案想象成类似于echo env(NAME_OF_VAR)之类的东西,尽管我似乎找不到它.该解决方案必须在sh中工作.

I can picture the solution being something like echo env(NAME_OF_VAR) although I can't seem to find it. The solution has to work in sh.

PS,我不能为此编写脚本,它必须是内置的unix命令(我知道,这很荒谬)

PS I can't write a script for this, it must be a built in unix command (i know, ridiculous problem)

谢谢(为您的荒谬表示歉意)

Thanks (and sorry for the absurdity)

推荐答案

您可以这样做:

printenv VARIABLE_NAME

这篇关于UNIX,获取环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆