#!/bin/bash 

#quiz3 -  add script code in this file to carry out the specified tasks.
#         
#         When you are done,  package the three files (quiz3.sh, timing.txt, session.txt) in a tar.gz file 
#           and submit with handin.   


printf "$0  this is `uname -s` running on `uname -m` processor \n"
printf "$0  Current directory: $PWD,  Today's date is `date`, this is week `date +"%V"`.\n\n"

#This also works...
#if test $# -eq 0
if [ $# -eq 0 ]
  then
    echo "You are ok for now with no arguments "
fi

#Question 1
#To work this out you can do this on separate lines, You can combine commands in one line 
# if this is convenient.
# set X to  MetersXY
# set Y to  Money$XY   (yes....it needs to have the dollar sign)
# Create a third variable Z and set it so it concatenates the X and Y adding one blank space separator. 
# For example, if X and Y were set to  A and B,   then when we print Z we would see 'A B'  (three characters).
# Show these Question 1 commands on separate lines or in a single command line.
X=MetersMXY
Y=Money\$XY
Z="$X $Y"
echo $Z


#Question 2
#Look at the wordsList.txt file- this is a portion of a dictionary file on our system.
#In a single command line (i.e., create a pipeline), create a new output file of names ,
#  call it wordUpdate.txt,  that is sorted (by first letter, ties broke with 
# second character, so on)  and that has all names that begin with Brad removed.
# This must run in a single command line, using ONLY grep and sort (pipes and redirects are ok)
grep -v "Brad" wordList.txt | sort >  wordUpdates.txt 


#Question 3
#You heard that there is a command that can be used to restart 
#networking a Ubuntu system. However you do not remember the exact name or 
#where the command is located.  So like a good sys admin, you consult google
#and learn that the command  is 'sudo /etc/init.d/networking restart'
#But assume you did not learn the full path, instead you were told that
# the command file name was networking and that it contained the word 'restart'.
#How can you use the find command to narrow down your search?  The results of the command 
#can include multiple hits....as long as one of the hits is /etc/init.d/networking .
#sudo find / -name "*networking*"  -exec grep 'restart' {} \;
sudo find / -name "*networking*"  -exec grep -H 'restart' {} \;

#Question 4 Run the command 'script --timing=timings.txt session.txt' to record your everything
#keystrokes and term output.  Run the commands for Questions 1 - 3.  In other words, don't
#just run ./quiz3.sh but run each command separately.  
# To replay :  scriptreplay --timing=timings.txt session.txt 

#Last step is to package the three files (quiz3.sh, timing.txt, session.txt) in a tar.gz file 
#and submit with handin.   
tar -cvzf quiz3.tar.gz *.*



exit



