Advanced Exercises


9.

What lines do you need to change in the Bourne Again Shell script command_menu (page 547) to turn it into a TC Shell script? Make the changes and verify that the new script works.

10.

Users often find rm (and even rmi) too unforgiving because it removes files irrevocably. Create an alias named delete that moves files specified by its argument(s) into the ~/.trash directory. Create a second alias named undelete that moves a file from the ~/.trash directory into the working directory. Put the following line in your ~/.logout file to remove any files that you deleted during the login session:

/bin/rm -f $HOME/.trash/* >& /dev/null 


Explain what could be different if the following line were put in your ~/.logout file instead:

rm $HOME/.trash/* 


11.

Modify the foreach_1 script (page 370) so that it takes the command to exec as an argument.

12.

Rewrite the program while_1 (page 371) so that it runs faster. Use the time builtin to verify the improvement in execution time.

13.

Write your own version of find named myfind that writes output to the file findout but without the clutter of error messages, such as those generated when you do not have permission to search a directory. The myfind command should accept the same options and arguments as find. Can you think of a situation in which myfind does not work as desired?

14.

When the foreach_1 script (page 370) is supplied with 20 or fewer arguments, why are the commands following toomany: not executed? (Why is there no exit command?)




A Practical Guide to UNIX[r] for Mac OS[r] X Users
A Practical Guide to UNIX for Mac OS X Users
ISBN: 0131863339
EAN: 2147483647
Year: 2005
Pages: 234

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net