Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

***************************************************** * USE UBUNTU TERMINAL MODE

ID: 3601023 • Letter: #

Question

*****************************************************
   *   USE UBUNTU TERMINAL MODE COMMANDS ONLY          *
   *   DO NOT USE ANY EDITORS TO CREATE THIS PROGRAM   *
   *****************************************************


1) Using your name, create a file called lastNameFirstNameInitialpgm3.sh
    ex: robinsonMpgm1.sh


2) Append to the above file the necessary commands that when this file is executed
    it will display the following:

    **************************************************
    Author   : Your Name
    Course   : Course Name and Times
    Professor: Michael Robinson
    Program : Program Number, Purpose/Description
               A brief description of the program
    Due Date : mm/dd/yyyy

    I certify that this work is my own alone.
    **************************************************

    and STOP, waiting for the user the press ANY KEY TO CONTINUE

      
3) Append to the previous file the necessary LINUX COMMANDS to display the following:

    a) Hello my name is: LINUX COMMANDS
    b) My user name is: LINUX COMMANDS
    c) Todays date and time is: LINUX COMMANDS
    d) This file has x lines LINUX COMMANDS
    e) This file has x words LINUX COMMANDS
    f) This file has x bytes LINUX COMMANDS
    g) Please enter any number LINUX COMMANDS
    h) Your number LINUX COMMANDS * 2 = XXX
    i) STOP, waiting for the user the press ANY KEY
    j) Display a new clean screen     
    k) Ask Enter a line of numbers to be added LINUX COMMANDS
    L) Using the enhanced for loop, display all numbers entered, delaying the output
        of each number by 1 second each,
        then display the total of adding thoses numbers as follows:
        ex: 20 5 3 = 28
    m) Using a while true loop, request, accept and display data until it ends on
        input mod 5 = 0
        this uses if else
  

Explanation / Answer

Code:

#******************************************

#Author:   Tom Cruise

#Course:    CSE123

#Professor:   Charles Babbage

#Program:   Program Number, To display some text to the screen,

#       and do some interactive programming.

#Due Date:   26/10/2017

#I certify that this work is my own alone.

#*****************************************

#ID

#Declare variable

num = 0

#Declare variable

num3=0

#Display message

echo 'Hello my name is: XXX'

#Display message

echo 'My user name is: $USER'

#Display message

echo 'Todays data and time is:' $(date)

#Display message

echo 'This file has' $(wc -l < $0) 'lines'

#Display message

echo 'This file has' $(wc -w < $0) 'words'

#Display message

echo 'This file has' $(wc -c < $0) 'bytes'

#Display message

echo 'Please enter any number'

#Read number

read num

#Display number

echo "Your number = $((num * 2))"

#If count matches

if [ $# -ne 2 ]

then

    #Display message

    echo "Usage - $0   x    y"

   

    #Display message

    echo " Sum "

  

#Exit

    exit 1

fi

    #Display message

    echo "Sum of $1 and $2 is `expr $1 + $2`"

SampleOutput:

sh-4.2$bash-fmain.sh 511Hellomynameis:XXX

Myusernameis:$USER

Todaysdataandtimeis:ThuOct2017:24:53UTC2017

This

file

has

66lines

This

file

has

166words

This

file

has

1090bytes

Pleaseenteranynumber

2

Yournumber=4

Sumof5and11is16sh-4.2$

This

file

has

66lines

This

file

has

166words

This

file

has

1090bytes