Database Reference
In-Depth Information
$ pwd
/home/vagrant
This is as simple as it gets. You just executed a command that contained a single
command-line tool. The command-line tool pwd (Meyering, 2012) prints the name of
the directory where you currently are. By default, when you log in, this is your home
directory. You can view the contents of this directory with ls (Stallman & MacKenzie,
2012):
$ ls
topic
The command-line tool cd , which is a Bash builtin, allows you to navigate to a differ‐
ent directory:
$ cd book/ch02/
$ cd data
$ pwd
/home/vagrant/book/ch02/data
$ cd ..
$ pwd
/home/vagrant/book/ch02/
The part after cd specifies to which directory you want to navigate to. Values that
come after the command are called command-line arguments or options. The two
dots refer to the parent directory. Let's try a different command:
$ head -n 3 data/movies.txt
Matrix
Star Wars
Home Alone
Here we pass three command-line arguments to head (MacKenzie & Meyering,
2012). The first one is an option. The second one is a value that belongs to the option.
The third one is a filename. This particular command outputs the first three lines of
the file ~/book/ch02/data/movies.txt .
Sometimes we use commands and pipelines that are too long to fit on the page. In
that case, you'll see something like the following:
$ echo 'Hello' \
> ' world' |
> wc
The greater-than sign ( > ) is the continuation prompt, which indicates that this line is
a continuation of the previous one. A long command can be broken up with either a
backslash ( \ ) or a pipe symbol ( | ) . Be sure to first match any quotation marks
( " and ' ). The following command is exactly the same as the previous one:
$ echo 'Hello world' | wc
Search WWH ::




Custom Search