#!/bin/bash
# this script redirects the output of a list of commands to a text file

# first clear the terminal window 
clear
echo "angelaCarpenter.txt" >angelaCarpenter.txt
echo "Question 2.2 CATC Assignment">>angelaCarpenter.txt
echo  >>angelaCarpenter.txt
echo "Angela Carpenter">>angelaCarpenter.txt
# append to text file for the rest of the commands
echo >>angelaCarpenter.txt
echo "This text file contains the output of the commands marked by an asterisk for question 2.2 ">>angelaCarpenter.txt
echo >>angelaCarpenter.txt

echo "you can view the text file by using cat command as follows:  cat angelaCarpenter.txt"
echo >>angelaCarpenter.txt
echo "the following list of commands are executed and their output redirected to angelaCarpenter.txt" >>angelaCarpenter.txt
echo "date, hostname, uptime, arch, uname -a, uptime, whoami, who, finger, w, top and history " >>angelaCarpenter.txt
echo >>angelaCarpenter.txt
echo >>angelaCarpenter.txt
echo -n "date command shows the current  system, date and time:  " >>angelaCarpenter.txt 
echo  >>angelaCarpenter.txt
date >>angelaCarpenter.txt
echo  >>angelaCarpenter.txt
echo -n "Hostname shows the current host system is ">>angelaCarpenter.txt
echo  >>angelaCarpenter.txt
hostname >>angelaCarpenter.txt
echo -n "Arch commands shows the machines hardware architecture type is ">>angelaCarpenter.txt
arch >>angelaCarpenter.txt
echo >>angelaCarpenter.txt
echo "Uname - a shows some system information including the kernel name, the network node hostname, the release version number, the kernel version, the machine hardware name, the processor type, the hardware platform and the operating system " >>angelaCarpenter.txt 
echo  >>angelaCarpenter.txt
uname -a >>angelaCarpenter.txt
echo >>angelaCarpenter.txt
echo -n "Uptime shows that the system has been up and running for the following number of days, hours and minutes " >>angelaCarpenter.txt
uptime>>angelaCarpenter.txt
echo  >>angelaCarpenter.txt
echo -n "Whoami - The username of the user running the commands is " >>angelaCarpenter.txt
whoami >>angelaCarpenter.txt
echo >>angelaCarpenter.txt
echo "Who command shows the names of the users who are currently logged in : ">>angelaCarpenter.txt
echo >>angelaCarpenter.txt
who>>angelaCarpenter.txt
echo  >>angelaCarpenter.txt
echo "Finger command shows some information about the system users " >>angelaCarpenter.txt
echo >>angelaCarpenter.txt
finger >>angelaCarpenter.txt
echo >>angelaCarpenter.txt
echo "w - shows the current activity on the machine - who is logged in and what they are doing">>angelaCarpenter.txt
echo  >>angelaCarpenter.txt
w >>angelaCarpenter.txt
echo >>angelaCarpenter.txt
echo "top command shows the linux commands that are currently running and some system information about them" >>angelaCarpenter.txt
echo  >>angelaCarpenter.txt
echo "Note - you may need to press q to quit from the top command "
top >>angelaCarpenter.txt
echo  >> angelaCarpenter.txt
echo "and finally the output of the history command " >>angelaCarpenter.txt
history >> angelaCarpenter.txt

echo "thats all for now - the output of the commands has been directed  to angelaCarpenter.txt"
echo " Note that you can see the text file created from running this program by entering cat angelaCarpenter.txt"
echo " you can also use the head and tail commands to see just the start and the finish of the file "

echo "goodbye"
                                          

