Creating and Removing Files and Directories
Creating and Removing Files and Directories
$ touch new_file
$ mkdir new_directory
If you want to create a new directory and another nested directory inside of it
(or more of them), you can use the p option.
$ mkdir -p new_directory/another_new_directory_inside
You don't need the option of the parent directory already exists. If you want to
remove the directory, use the rmdir command.
$ rmdir directory_name
This will only remove empty directories. To remove non-empty ones, you can
use the rm command with the r (recursive) option.
$ rm -r non_empty_directory
$ rm filename
If the filename has some special characters (like an asterisk, square brackets,
whitespaces) you need to put it in quotes or you can escape each special
character by prepending a slash before it. If you use autocompletion, the shell
will do that for you.
Pay attention in macOS, because the operating system is case insensitive.