https://drive.google.com/file/d/19ABeAe7vBZO1jv8TQygNYd0iiTD8AdP9/view?usp=sharing

1. Understanding Shell Expansion and Quoting

Explanation

The shell processes (or "expands") commands before executing them. By default, multiple spaces between words are collapsed into a single space. To preserve spacing or special characters, you must use quoting.

Commands and Examples

echo Hello world                 # Output: Hello world
echo Hello           world       # Output: Hello world (spaces collapsed)
echo 'Hello           world'    # Output: Hello           world (single quotes preserve everything)
echo "Hello           world"    # Output: Hello           world (double quotes also preserve spaces)

Lab Steps

  1. Run each of the above echo commands.
  2. Observe how unquoted spaces are collapsed, but quoted ones are preserved.

Tips & Warnings


2. Shell Variables: System vs. User-Defined

Explanation

Commands

echo $SHELL        # Shows your current shell (e.g., /bin/bash)

# Create a user variable
var1=100
echo $var1         # Correct: outputs 100
echo var1          # Wrong: outputs literal "var1"
echo 'var1'        # Outputs literal "var1" (no expansion in single quotes)
echo "var1"        # Outputs literal "var1" (no $, so no expansion)