oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

An Introduction to Tiger Terminal, Part 4
Pages: 1, 2, 3, 4, 5

Less is More

The output of our script scrolled out pretty quickly. Sometimes, it's desirable to see the output of our script in smaller chunks. We can use the "pipe" symbol (|) and the less command to see the output in more manageable chunks. The pipe symbol is done with the Shift and \ (backslash) keys. The command looks like this:

norburym15:~ norburym$ | less

And the output looks like this:

Figure 16. Output of | less

Use the Return key to move to the next line of output. Use the Q key to quit out of less and bring you back to your shell prompt.

Another Simple Script

Now that I have successfully written a script that can tell me who has user accounts on my PowerBook, I want to see what these other users have in their Documents folders.

1. Open a new Terminal window.
2. cd to your new scripts directory.
3. Create a new shell script called with nano:

Figure 17. without comments

Figure 18. with comments

4. Save the script (^O) and exit (^X).
5. Make the file executable with chmod +x
6.. Run the shell script and you'll be prompted for your admin password:

Figure 19.

6. Type in your admin password and hit Return:

Figure 20. After typing in your password

7. Navigate to your documents folder and cat (output) the contents of userfiles.txt.

Figure 21. Output of userfiles.txt

Pages: 1, 2, 3, 4, 5

Next Pagearrow