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.
Read the man pages on the following entries :
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 :
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.
# Consider the following : # assign the string "It's translated" including double quotes to a variable. var='"It'\''s translated"' echo $var "It's translated" # If you match carefully, you'll see that the 1st set of single quotes is closed before the backslash quotes a lone single quote and then a second pair of single quotes encloses the rest of the string.
You can break this down into 3 aliases. 1st alias does the file exit test, the second does the read test, and the 3rd (vfile) combines them. This will make it easier to test.
You may also have to embed parentheses inside paretheses to get the proper logic. You may need to use \ or close and open different quotes to quote the ' in can't
The alias should do the following :
The Backup alias should do the following :
#Try the following : fn="/var/www/file1" echo $fn|sed "s#^.*/##" nfn=`echo $fn|sed "s#^.*/##"` echo $nfn #sed removes all characters up to and including the last /
The alias should do the following :