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

TIME SENSATIVE LINUX 1) File1: Name LastName GPA ID Balance Fred Johnson 3.5 1 $

ID: 3784025 • Letter: T

Question

TIME SENSATIVE LINUX

1) File1:

Name   LastName        GPA    ID        Balance

Fred     Johnson           3.5       1          $1250

John    Carlton            4.0       2          $3250

File2:

City                             Phone                          Email                           ID

San Francisco              415-222-333               fred@xmail.com         1

San Jose                      408-333-2121             steve@ymail.com        2

  

Print the email and balance of those students who have a GPA of 4.0. Use join and awk commands.

2)

File1:

Name   LastName        GPA    ID        Balance

Fred     Johnson           3.5       1          $1250

John    Carlton            4.0       2          $3250

File2:

City                             Phone                          Email                           ID

San Francisco              415-222-333               fred@xmail.com         1

San Jose                      408-333-2121             steve@ymail.com        2

Use cut and paste commands to have the LastName, phone and email of all students in one file.

3)

File1:

Name   LastName        GPA    ID        Balance

Fred     Johnson           3.5       1          $1250

John    Carlton            4.0       2          $3250

File2:

City                             Phone                          Email                           ID

San Francisco              415-222-333               fred@xmail.com         1

San Jose                      408-333-2121             steve@ymail.com        2

Use the awk command to display the last names that contain John as part of the last name.

4)

Write a script to clear the screen, move the cursor to location 10, 12 and display:

                        Enter number1:

                        Enter number2:

                        Enter number3:

                        Sum =

                        Average =

Move the cursor to appropriate locations and read the three numbers. Then calculate the sum and average and display them at appropriate locations.

Explanation / Answer

1.The Requirement is to join the files namely File1 and File2.

By Using the Join command we can combine the Files File1.txt and File2.txt and the awk is an Pattern language processing command and a printing tool.hence these commands are to be combined by using the AND operator.and it will search for the pattern where the GPA=4.0 finally the command will be as follows.
Join -a File1.txt File2.txt && awk '{print $email " " $Balance && 'GPA=4.0'}'

2.

we need to Cut some columns in both the files file1 and file2.and we need to paste the extracted columns to the file.here i used the File1 to do the thing.

here -f specifies the columns which we would like to extract.and all the extracted columns are temporarily saved on the clipboard and we need to padte them.
cut -f=Lastname,phone,email -s -File1.txt,File2.txt | paste -d File1.txt

3.
Use the awk command to display the last names that contain John as part of the last name.

Here we need to search
awk ' /'John'/ {print $Lastname}' File1.txt

4.

#!/bin/bash
# Screen clearing and finding sum and average

$ clear

Move the cursor up N lines:[<N>A

$ echo -en "[10"
echo "Enter number1"
echo "Enter number2"
echo "Enter number3"
read n1 n2 n3
Sum='expr $n1+$n2+$n3'
echo "Sum=$Sum"
Avg='expr $sum'/3
echo "Average=$Avg"