IT 244: Introduction to Linux/Unix
Homework 9

Due

Sunday, April 7th at 11:59 PM

What You Need to Do

Setup

Specification

.bash_profile

  1. Go to your home directory and edit .bash_profile to define the global variable glenn whose value is the absolute pathname of my home directory.
  2. Again in .bash_profile define an alias gh which will take you to my home directory using the variable defined above.
  3. Also in .bash_profile define a function go_show, that will
    The directory this function takes you to will be specified as an argument to the function on the command line.
    You will need to use a positional parameter to do this.

hw9.sh

  1. Run the source command on your ~/.bash_profile startup file in your home directory.
    Print to the terminal the value of the variable glenn.
  2. Using a pipeline, grep and a command that will show all your global variables, print to the screen the full definition of the variable glenn.
    Do not use echo to do this.
    The command to show all global variables was mentioned in the first class were global variables were discussed.
  3. Aliases and functions are not global, so they cannot normally be run inside a shell script.
    That is why I asked you to run source on ~/.bash_profile.
    Once you do that, the aliases and functions defined in you .bash_profile will be available inside your the process running your script.
    Run a command that will show the definition of the function go_show
  4. Use the function go_show to move to my home directory using the global variable glenn.
  5. Run a command that will show all the aliases you have currently defined.
  6. Run a command that will show the last 20 commands in your history list.
  7. Create the variable glenn_home whose value is the following
    The home directory of my instructor is /home/ghoffman
    When you define this variable, you must use the value of the variable glenn.
    Also, the value assigned to glenn_home must be contaned in a single string and you must use the value of glenn inside this string.
    Now print the value of glenn_home to the terminal.

Testing

Copyright © 2020 Glenn Hoffman. All rights reserved. May not be reproduced without permission.