Question: Chapter 8 , Lab 3 : History, Aliases, and Functions ( 2 5 Minutes ) Learning Objectives and Outcomes In this lab you will learn
Chapter Lab : History, Aliases, and Functions
Minutes
Learning Objectives and Outcomes
In this lab you will learn to use the bash history feature to view and repeat previous commands. You will also experiment with
aliases that can translate one usually shorter command into another, and functions that can perform a series of commands.
Reading
Read the sections on history Sobell using exclamation points to reference events Sobell pages aliases Sobell
pages and functions Sobell
Procedure
Type the following commands:
$ head etcservices
$
$ who
$ date
Use the up arrow key to repeat a display of the last command.
Use history and tail Sobell to list the most recent commands you issued.
It is okay if you have only the preceding five commands in your history list.
Read "Using an Exclamation Point to Reference Events" in Sobell
a
Repeat the ls etc command using that command's event number Sobell
b
Repeat the date command by specifying it as the th preceding command.
Be careful: Each time you issue a command, the relative number of each preceding command changes.
You might want to give another history command before you proceed.
c
Repeat the previous command using
Create an alias Sobell that translates the command into date.
Make sure the new alias works.
Display the alias.
Create an alias that translates the command ls into ls Test the alias.
Give a ls command that does not use the alias.
Remove the alias and show that the alias no longer exists.
Where would you define an alias so that it is available each time you log in
Write a oneline function Sobell page named welcome that displays Welcome to my computer.
Demonstrate that the function works.
Write a function named long that displays the date and a long listing of the working directory. Demonstrate that the
function works.
Where would you define a function so that it is available each time you log in
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
