Lesson 5 / 31
Creating Files & Directories
Create files and nested directories with touch and mkdir -p, and handle names with spaces.
touch & mkdir
touch creates an empty file (or updates its timestamp). mkdir creates a directory.
touch notes.txt
mkdir projects
ls
Output:
notes.txt projects
Nested directories
mkdir -p creates parent directories as needed, without erroring if they already exist.
mkdir -p projects/app/src
ls -R projects
Output:
projects: app projects/app: src
Avoid spaces & special chars
File names with spaces need quotes or escaping: touch "my file.txt" or touch my\ file.txt. Prefer hyphens or underscores instead.