0% found this document useful (0 votes)
5 views2 pages

Creating and Removing Files and Directories

The document provides instructions on managing files and directories using Bash and Z Shell commands. It covers creating and removing files and directories, including the use of commands like touch, mkdir, rmdir, and rm. Special attention is given to handling filenames with special characters and case sensitivity in macOS.

Uploaded by

akym
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Creating and Removing Files and Directories

The document provides instructions on managing files and directories using Bash and Z Shell commands. It covers creating and removing files and directories, including the use of commands like touch, mkdir, rmdir, and rm. Special attention is given to handling filenames with special characters and case sensitivity in macOS.

Uploaded by

akym
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

"Managing Files Using Bash and Z Shell" course by Mateo Prigl at Pluralsight

Creating and Removing Files and Directories


To create an empty file, use the touch command. The first argument of the
command should be the name of the new file. If the file exists, this will update
the files modification time.

$ touch new_file

To create a new directory, use the mkdir command.

$ 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.

1/2 © Copyright 2020 by Pluralsight


"Managing Files Using Bash and Z Shell" course by Mateo Prigl at Pluralsight

$ rm -r non_empty_directory

Files can be removed by just using the rm command.

$ 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.

2/2 © Copyright 2020 by Pluralsight

You might also like