The env and set commands are both used in the shell, but they serve different purposes and display different types of information:
env
- Purpose: The
envcommand is primarily used to display the environment variables for the current shell session. - Output: It lists only the environment variables, which are variables that are available to child processes. These variables typically include system settings and user-defined variables that are exported.
- Usage: You can also use
envto run a command in a modified environment.
Example:
env
set
- Purpose: The
setcommand is used to display all shell variables, including both environment variables and shell functions. - Output: It lists all variables (both local and global) defined in the current shell session, including shell options and functions.
- Usage: It can also be used to set shell options and define variables.
Example:
set
Summary
- Use
envto see environment variables specifically. - Use
setto see all shell variables and functions, including local variables.
