Aliases - CSCI 330
60 points

Due Thursday, 12 October 2017, 11:59 PM.

Create a set of aliases that perform the tasks described below .

The easiest way to create and edit these is to put them in a text file. You can then source this file to declare or redefine the aliases in the current login shell. If you named the file aliasAssn, you can initialize them with the command sequence :

. aliasAssn

The source command will read each line of the file and enter it into the command line buffer as if you were typing it in yourself. Because you are sourcing the command sequence, DON'T put in the shebang (#!/bin/bash). But, do put in comment lines. These will be ignored by the command interpreter.

The aliases will now be loaded into your current login shell. Test your aliases. If you find mistakes, simply edit your aliasAssn file, fix your mistakes, save, and source the file again.

To prepare for this assignment, do the following.

Create a directory under your home directory called Backup.

Include comments in the aliasAssn file before each alias. Start comment lines with a #.

Give the problem number, a general description ( you don't have to copy the problem verbatim ) and any comments to help yourself.

To figure out what comments to use, pretend that you were going to be a TA next year for this course and that you were going to use your assignment as a key to counsel any students asking for help. How would you describe your answers so you could understand it after a year.

When creating an alias, if possible, use the environmental variables instead of specific values to make the alias portable.

For example, if you need to access your home directory, use the variable $HOME instead of /home/hopper/z######. This will allow your T.A. to test your functions in her/his account.

Be careful to notice whether the alias has caps in its name.

Write the following aliases :


1.(7) Write a alias called tstamp that returns the current time as a string of digits representing the current time. See the date man pages for correct options.

Choose formatting options that generates a single string of digits( numbers ) with no white-space but with all digits, so a 4 digit year, a 3 digit day of the year, hours as 2 digits in 24 hour units, and minutes and seconds in the range 00-59.

The purpose of this is to generate a string that can be used by another alias to timestamp a backup copy of a file by adding a filename extension.



2.(7) Write an alias called getname that :

3.(15) Write an alias called vfile that : Useful pieces of info :

4.(9) Write an alias called backup that backs up a named file to the Backup directory. Use $HOME/Backup when referencing the Backup folder.

The alias should do the following :

If you do the cp correctly, this will work even if the file to be backup is provide with a path.


5.(15) Write an alias called Backup that backs up a named file to the Backup directory, appending a timestamp generated by the tstamp alias. Use $HOME/Backup when referencing the Backup folder.

The Backup alias should do the following :



6.(7) Write an alias called finder that searches for a file.

The alias should do the following :

email the file to me (berezin) on hopper/turing.