Bash Wiki
Posts (Latest 30 updated) :
Read all
Contents:
  1. [Linux] Bash printenv Uso equivalente: Print environment variables
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[Linux] Bash printenv Uso equivalente: Print environment variables

The printenv command is used to display the current environment variables in a shell session.

Overview

The printenv command prints all or part of the environment variables that are currently set in your shell. Environment variables are key-value pairs that can affect the behavior of processes on your system.

Usage

The basic syntax of the printenv command is as follows:

printenv [options] [arguments]

Common Options

  • -0, --null: Output a null character after each variable instead of a newline.
  • variable: If you specify a variable name as an argument, printenv will display the value of that specific variable.

Common Examples

Here are some practical examples of using the printenv command:

  1. Display all environment variables:
    printenv
    
  2. Display a specific environment variable (e.g., PATH):
    printenv PATH
    
  3. Display a specific environment variable (e.g., HOME):
    printenv HOME
    
  4. Display all environment variables with null character as delimiter:
    printenv -0
    

Tips

  • Use printenv when you need to quickly check the values of environment variables without additional formatting.
  • Combine printenv with other commands like grep to filter specific variables. For example:
    printenv | grep USER
    
  • Remember that printenv only shows the environment variables that are currently set; it does not modify them. Use commands like export to set or change environment variables.