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

Bash UNIX LINUX Shell Script Write a script in the directory that goes through t

ID: 3813098 • Letter: B

Question

Bash UNIX LINUX Shell Script

Write a script in the directory that goes through the column the user specifies (1-10) of all 4 files and calculates the min and the max values. This means that if the user specifies column 5, then go through column 5 of all 4 files and all that should give only one min and one max. You subtract the min from the max and then divide that value by two (finding the average).

You then replace values in column one for all 4 files that are less than the average AND greater than the min with ‘ttt’ and ones that are greater than or equal to the average AND less than the max with ‘gcc’.

Here is how the script should work: (the script should ask the user) Please enter a the column you wish to change: 7 (the user enters column 7 in this case, the script goes through column 7 of all the 4 files and arrives at one max and one min. It subtracts the min from the max and divides the difference by 2 to give you J.

Then it goes through column 7 of all 4 files and changes any value less than the J and greater than the min with ‘ttt’ and ones that are greater than or equal to J and less than the max with ‘gcc’.

Please make sure you check the user input. If the user puts in anything that is not 1-10 then, you should give them an error message.

Explanation / Answer

max=0 cat file.txt|

while read LINE

do

fir=`echo $LINE|

awk '{print $2}'` sec=`echo $LINE|

awk '{print $3}'` if [ $fir -gt $max ];

then max=$fir fi if [ $sec -gt $max ]

;then max=$sec

fi

done

grep $max file.txt

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote