Session - 11 (Shell Variables)
Session - 11 (Shell Variables)
2. User-Defined Variables
• These are created manually by users for storing temporary data.
• By default, user-defined variables are only available in the current shell.
• Naming rules:
o Can contain letters, numbers, and underscores (_).
o Cannot start with a number.
o Should not have spaces around the equal sign.
• Example:
# my_var="Hello, Linux!"
# echo $my_var # Output: Hello, Linux!
• User-defined variables can be exported to child processes using:
# export my_var
Shell Variables in Linux
prompt>
We can further modify it using predefined shortcuts:
vikasnehra@localhost:~$ PS1='\u@\h:\w@\t\$ '
vikasnehra@localhost:~@07:34:21$