In the Korn shell (ksh), variables are used to store values that can be used in scripts and commands.
To create a variable in ksh, you can use the following syntax:
variable_name=value
For example, to create a variable called name
and assign it the value John
, you can use the following command:
name=John
To access the value of a variable, you can use the $
symbol followed by the variable name.
For example, to print the value of the name
variable, you can use the following command:
echo $name
This will print John
to the terminal.
You can also use variables in commands and scripts.
For example:
echo "Hello, $name!"
This will print Hello, John!
to the terminal.
You can use the export
command to make a variable available to child processes.
For example:
export name
This will make the name
variable available to child processes of the current shell.