less
To get an idea of what is in the files you just downloaded, type:
cd Providence/Ethan
less eth01.cha
What information is in the metadata at the top of each file? (Hint: child language researchers use the format y;m.d to indicate a child's age in years;months.days)
(less may seem like a funny name for this command which shows you more of the file; it's because there was an earlier similar command called more, so when this newer version was developed the developers decided to give it a cute name. UNIX developers like cute names.)
When you are looking at a file using less, you can scroll up and down using the arrow keys or <PageUp>/<PageDown>. <space> also acts like <PageDown> and <Enter> acts like <down-arrow>.
What do you see in the rest of the file?
(Hint: the string of numbers at the end of each line is a code that links to a time point in the audio recording of this data. The audio isn't included here but can be obtained from the CHILDES database.)
One final useful thing you can do with less is search for a particular string in the file by typing / followed by the string. Try it: type
/the
followed by ENTER. You should see all of the instances of the being highlighted.
To stop viewing the file and go back to the terminal command line, type q.
Actually, the eth01.cha file maybe is not so interesting. Look now at eth50.cha. What are some of the main differences between the data in these two files? Can you think of an explanation for those differences? (If you want to look at both files simultaneously, you could start a new terminal and open one file in each terminal.)
man
We don't really need to look at the first 10 lines of each file to see the ages, we only need the first five lines. If we could print only the first five lines, we could see the information we want more compactly. Most UNIX commands, including head, have many possible options to change their behavior. To see what options are available, look at the manual for the command:
man head
You should see:
HEAD(1) User Commands HEAD(1)
NAME
head - output the first part of files
SYNOPSIS
head [OPTION]... [FILE]...
DESCRIPTION
Print the first 10 lines of each FILE to standard output. With more
than one FILE, precede each with a header giving the file name. With
no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options
too.
-c, --bytes=[-]K
print the first K bytes of each file; with the leading `-',
print all but the last K bytes of each file
-n, --lines=[-]K
print the first K lines instead of the first 10; with the lead-
ing `-', print all but the last K lines of each file
-q, --quiet, --silent
never print headers giving file names
-v, --verbose
always print headers giving file names
...
Note: you should be able to move up and down in the man pages using the same keys you used for less [I hope; the default for the student account might not allow you to move upwards...], and you can also return to the command line using q.
The man page starts with the name of the command and a brief synopsis of how to use it. In this case, it says that the head command can be followed by zero or more options (sometimes called flags) and then zero or more files as arguments (things to act on). The square brackets indicate that these options and files need not be included at all, and the ... indicate that you can include more than one of each.
The description after the synopsis says what will happen if you include zero or multiple files. (Standard input refers to the text you input in the terminal. Try entering head with no filename to see how this works. You will need to enter some more text after that! To quit, type Ctrl-c.)
The next part of the description tells you what the possible options are and if they require arguments themselves. Many (in this case all) options have both a short and a long form, which are equivalent. For example, to print just the first 5 lines of each file, we could either use:
head -n5 eth01.cha
or:
head --lines=5 eth01.cha
(To try this yourself, you will need to either use another terminal or quit the man page first by typing q.)
The K specified in the description is a variable indicating a required argument to the -n option. Here we use the value 5 for K. Notice that this option also has a non-required argument [-] so if we wanted to print all but the last 5 lines we could type:
head -n-5 eth01.cha
As noted above, you can specify multiple options at once. Compare the output of the following commands:
head -n5 *.cha
head -n5 -q *.cha
Now that you know how to read a man page, you may want to look at the man pages for some of the other commands we've seen to see what options are available for them.
There is also a lot of help about these commands on the Internet. You can find more examples or maybe a better explanation than the man page has. If you know the name of the command you want to use, like grep, try searching for UNIX command grep. If you know what you want to do but not the name of the command, searching is trickier, but try searches like UNIX search regular expression or even UNIX find string in file. Get in the habit of looking for help--you will start to recognize some of the main help forums and which ones are most useful to you.