05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

less (more)<br />

less is a pager, which allows you to scroll through large amounts of text that may normally<br />

scroll right by you in the terminal. You learned how pagers worked with the man command,<br />

which automatically runs in a pager (which by default in <strong>Leopard</strong> is actually less)—however,<br />

sometimes it’s useful to use a pager with other commands as well. For example, when we use the<br />

ps aux command, we are presented with lots of information scrolling right by; however, if we<br />

pipe the ps aux command into less, then we can scroll around our output just as we scrolled<br />

around our man pages. An example of this is the following:<br />

<strong>Leopard</strong>:~ scott$ ps aux | less<br />

USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND<br />

scott 304 5.9 -8.1 795272 170688 ?? S 8:15PM 24:06.93 /Applicati<br />

root 39 0.7 -0.3 30440 6192 ?? Ss 4:14PM 0:05.56 /usr/sbin/<br />

windowse 62 0.1 -2.2 902716 45600 ?? Ss 4:14PM 5:30.36 /System/Li<br />

scott 307 0.1 -0.6 372104 12548 ?? S 8:17PM 1:10.59 /Applicati<br />

root 31 0.0 -0.1 27840 2408 ?? Ss 4:14PM 0:00.03 /usr/bin/W<br />

root 32 0.0 -0.4 303152 7440 ?? Ss 4:14PM 0:01.47 /Library/A<br />

root 33 0.0 -0.1 27824 2052 ?? Ss 4:14PM 0:00.01 /System/Li<br />

root 34 0.0 -0.1 27844 2328 ?? Ss 4:14PM 0:00.02 /usr/sbin/<br />

root 35 0.0 -0.1 28564 2696 ?? Ss 4:14PM 0:00.82 /usr/sbin/<br />

root 36 0.0 -0.1 27580 1088 ?? Ss 4:14PM 0:00.47 /usr/sbin/<br />

root 37 0.0 -0.0 27288 1016 ?? Ss 4:14PM 0:00.08 /usr/sbin/<br />

root 40 0.0 -0.3 31852 5772 ?? Ss 4:14PM 0:00.23 /usr/sbin/<br />

root 41 0.0 -0.1 27776 2780 ?? Ss 4:14PM 0:00.12 /usr/sbin/<br />

root 42 0.0 -0.1 28324 1716 ?? Ss 4:14PM 0:00.02 /usr/sbin/<br />

root 44 0.0 -0.3 29268 5316 ?? Ss 4:14PM 0:00.27 /usr/sbin/<br />

root 46 0.0 -0.0 27864 880 ?? Ss 4:14PM 0:00.15 /usr/sbin/<br />

root 50 0.0 -0.0 27252 708 ?? Ss 4:14PM 0:20.84 /usr/sbin/<br />

root 54 0.0 -0.3 30744 6768 ?? Ss 4:14PM 0:00.32 /usr/sbin/<br />

root 55 0.0 -0.1 27676 2184 ?? Ss 4:14PM 0:00.37 /usr/sbin/<br />

root 63 0.0 -0.3 37828 5512 ?? S 4:14PM 0:00.18 /usr/sbin/<br />

root 64 0.0 -0.5 37028 9752 ?? Ss 4:14PM 0:00.53 /System/Li<br />

scott 69 0.0 -0.4 82936 8332 ?? Ss 4:15PM 0:02.26 /System/Li<br />

:<br />

Using the arrow keys, we can now scroll through our output, and when we are done, we can<br />

quit the pager and return to our prompt by pressing Q.<br />

NOTE Another older yet extremely popular pager was called more. Although more was very<br />

popular, it was lacking in many ways—for instance, it would only allow you to scroll down (e.g.,<br />

you couldn’t go back once you scrolled past something). Because of this, less has largely<br />

replaced more; however, for backward compatibility, the more command has been linked with<br />

less, so the more command still works (although it will actually run less).<br />

find and whereis<br />

CHAPTER 18 INTRODUCING DARWIN AND THE SHELL 305<br />

find and whereis are two commands that work very differently, yet are both used to the same<br />

ends: finding something in the Darwin file system.<br />

find by default takes a path variable and presents a list of matches. Additionally, if a match<br />

is a directory, find will traverse that directory as well (find / will return every visible file on your<br />

hard drive!). Using regular expressions and wildcards can effectively narrow (or broaden) your<br />

search as needed. A simple find example may be something like this:

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

Saved successfully!

Ooh no, something went wrong!