Work with Files and Directories
Much of what you’ll need to do on the command line involves working with files in some way—creating, deleting, copying, renaming, and moving them. This chapter covers the essentials of interacting with files and directories.
Create a File
I want to begin by mentioning a curious command called touch
that serves two interesting functions:
When supplied with the name of a nonexistent file as an argument,
touch
creates an empty file.When supplied with the name of an existing file or folder as an argument,
touch
updates its modification date to the current date and time, marking it as modified.
Try entering the following command:
touch file1
Now use ls -l
to list the contents of your current directory. You’ll see ...
Get Take Control of the Mac Command Line with Terminal, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.