Summary
To create a file using your terminal, use the touch
command:
touch file-name
Details
The touch
command is used to create files in the terminal. If the file you are trying to create already exists in the folder you are in, it simply updates the modification and access time of the file.
To create a file named index.html
, enter the following command in your terminal:
touch index.html
To check that the file was created, enter the following command to print out the contents of your current folder:
ls
You should see the file listed in the output along with any other files and folders inside the current directory.
Create multiple files
To create multiple folders, pass in multiple folder names as arguments to the touch
command, like this:
touch index.html about.html
The above command will create files named index.html
and about.html
.
Exercises
Try the following command in your project folder:
touch main.css
References
Run the man touch
command in your terminal to learn more.