Unix Concepts   «Prev  Next»

Modifying Previous Command - Exercise

Using the History Feature

Objective:Use command history to display, repeat, and modify commands.

Exercise scoring

You will receive2 points for this exercise.

Submitting your exercise

This exercise is auto-scored. When you have finished, just click the Submit button to receive full credit.

Background/overview

In this exercise, you will set up the command history and enter random commands.
Then you will use the history feature to display, repeat, and modify your commands.

Instructions

  1. Log in to your course account.
  2. Type the script command to begin saving your UNIX session to a file named ex200-3:
    % script ex200-3
    
  3. Use the set history command to begin remembering up to 25 commands.
  4. Enter random commands so that you accumulate a list of commands. Harmless commands include ls, pwd, date, who, and clear.
  5. Use the history command to display your command history.
  6. Try a few history substitutions. Try the main forms, !pattern, !N, and !!, at least once.
  7. Create a new directory, but misspell the command as makedir instead of mkdir.
  8. Use quick substitution to correct makedir to mkdir.
  9. Use cd with the !$ word substitution to change to the directory you just created.
  10. Type exit to end the script command.
  11. Log out when you are done.

Exercise - Hints

If you enter the logout command, but it responds Not login shell, it means you forgot to end the script command.
Type exit and then logout.