printenv

>Usage

The printenv command in Unix is used to display the values of environment variables.

When run without arguments, it lists all environment variables. If you specify a variable name, it shows the value of that specific variable.

The printenv command is limited in terms of options, as its primary function is to display environment variables.

>Synopsis

printenv [variable-name]

>Examples

>printenv

Using printenv without any arguments lists all environment variables and their values.

Example:

Dots

-zsh

> printenv


USER=johndoe
HOME=/home/johndoe
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:
/sbin:/bin
SHELL=/bin/bash
LANG=en_US.UTF-8
LOGNAME=johndoe
TERM=xterm-256color
PWD=/home/johndoe/projects
EDITOR=vim

>printenv [VARIABLE]

Prints the value of a specific environment variable if [VARIABLE] is specified, otherwise printenv will produce no output for that variable.

Example:

Dots

-zsh

> printenv LANG


en_US.UTF-8

>printenv [VAR1] [VAR2]

Prints multiple specific environment variables if [VAR1] and [VAR2] are specified, otherwise printenv will produce no output for those variable.

>Quiz

Progress: Question ? out of ?

Question Title

Page written by Alessandro Tognoni