The Command Line, Enough of It
See What Is Here
You know where you are standing. The next question is what is there.
ls
ls
README.txt data report.py
This is your project, and it stays
Those three files are not scratch. They are this chapter’s project, they belong to you, and they persist. Close the tab, come back tomorrow, and ls will show you the same three names. A file you make in one lesson is still there in the next one.
That is worth pausing on, because until now everything you wrote lived inside a single exercise and vanished with it. From here what you make accumulates, which is the first way this course starts to resemble working on your own machine rather than answering questions.
Looking inside a directory
data in that listing is not a file, it is a directory. You can list its contents without moving into it, by naming it:
ls data
books.txt
ls with no ls data means “in there”. Most shell commands work this way: they act on the working directory unless you tell them something else.
Reading a file without opening it
cat prints a file’s contents straight into the
cat data/books.txt
The Left Hand of Darkness
Piranesi
Station Eleven
cat is for a quick look at something small. It has no scrolling and no way out of a long file. It simply prints everything and hands the prompt back. For a three-line file that is exactly what you want.
Notice what you typed: data/books.txt. That is a path: a route from where you are to the thing you want. The / separates each step of the route. You did not have to move into data to read something inside it; you just had to describe how to get there.
You are in /workspace and you type ls data. What are you asking for?
Next: moving the shell somewhere else, and what happens to your paths when you do.