Difference between env, environ and printenv

Difference between env, environ and printenv

env: env is a command in Unix-like operating systems that allows you to run a command in a modified environment. It can be used to set environment variables, remove or modify existing environment variables, or run a command with a specific environment. For example, you can run

env FOO=bar mycommand to run mycommand with the environment variable FOO set to bar.

environ: environ is a global variable in C programming that contains an array of strings representing the environment variables of the current process. Each string in the array is in the form "key=value", where "key" is the name of the environment variable and "value" is its value. You can use environ to access and modify environment variables in your C program.

printenv: printenv is a command in Unix-like operating systems that allows you to print the values of environment variables. It takes no arguments and simply prints the names and values of all environment variables. For example, you can run printenv to print the values of all environment variables in your current shell session.

nb: running env without any arguments is equivalent to running printenv, and it prints all the environment variables currently set in your shell session.