Previous Section  < Day Day Up >  Next Section

LAB 37: TILDE EXPANSION, QUOTES, AND COMMAND SUBSTITUTION

  1. Use the tilde to do the following:

    1. Print your home directory.

    2. Print your neighbor's home directory.

    3. Print your previous working directory.

    4. Print your current working directory.

  2. What variable holds the value of your present working directory? What variable holds the value of your previous working directory?

  3. Use the – to go to your previous working directory.

  4. Use the print command to send the following output to the screen. (The word enclosed in < > is a variable name that will be expanded, and words enclosed in [ ] are output of commands that have been executed; i.e., use command substitution.)

    
    Hi <LOGNAME> how's your day going?
    
    "No, <LOGNAME> you can't use the car tonight!", she cried.
    
    The time is [ Sun Feb 22 13:19:27 PST 2004 ]
    
    The name of this machine is [ eagle ] and the time is [ 31:19:27 ]
    
    

  5. Create a file that contains a list of usernames. Now create a variable called nlist that contains the list of usernames, extracted by using command substitution.

    1. Print out the value of the variable. How does command substitution affect the formatting of a list?

    2. Test this by setting a variable to the output of the ps –eaf command.

    3. What happened to the formatting?

    Previous Section  < Day Day Up >  Next Section