05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

That struts and frets his hour upon the stage<br />

And then is heard no more: it is a tale<br />

Told by an idiot, full of sound and fury,<br />

Signifying nothing.<br />

Now if we weren’t sure what this file was (or how long it was), we could use head to view<br />

just the first three lines:<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ head -n 3 soliloquy4<br />

Tomorrow, and tomorrow, and tomorrow,<br />

Creeps in this petty pace from day to day<br />

To the last syllable of recorded time,<br />

Likewise, we could use tail to view the last three lines:<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ tail -n 3 soliloquy4<br />

And then is heard no more: it is a tale<br />

Told by an idiot, full of sound and fury,<br />

Signifying nothing.<br />

NOTE Like many <strong>OS</strong>s these days, <strong>OS</strong> X keeps rather long log files about many of the things<br />

happening on the system. While there are many dedicated viewers for many of these files,<br />

these files are often very, very long. For such files, tail can be a godsend. For example, if you<br />

ran a busy web server for which you wanted to see the details of the last 50 hits, you could use<br />

tail -n 50 /var/log/httpd/access_log.<br />

To make a copy of our file, we would use the cp command:<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ ls<br />

soliloquy4<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ cp soliloquy4 macbethsolo<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ ls<br />

macbethsolo soliloquy4<br />

We could then create a new subdirectory:<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ mkdir <strong>Mac</strong>beth<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ ls<br />

<strong>Mac</strong>beth/ macbethsolo soliloquy4<br />

and then move one of the files into our new directory:<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ mv soliloquy4 <strong>Mac</strong>beth/soliloquy4<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ ls<br />

<strong>Mac</strong>beth/ macbethsolo<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ ls <strong>Mac</strong>beth/<br />

soliloquy4<br />

We can also use the mv command to rename a file:<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ mv macbethsolo tomorrow<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ ls<br />

<strong>Mac</strong>beth/ tomorrow<br />

Next we could try to remove our <strong>Mac</strong>beth directory:<br />

<strong>Leopard</strong>:~/Documents/Shakespeare scott$ rmdir <strong>Mac</strong>beth/<br />

rmdir: <strong>Mac</strong>beth/: Directory not empty<br />

CHAPTER 18 INTRODUCING DARWIN AND THE SHELL 299

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!