TCS IRA/PRA 6TH DECEMBER BASH /UNIX QUESTION AND SOLUTION 2021

HELLO DORAEMONS ,

 WELCOME TO MY BLOGPOST.IN THIS BLOG POST  I HAVE SHARE THE PREVIOUS ASKED BASH\UNIX QUESTIONSASKED IN LAST IRA AND ALSO THE SOLUTION TO THOSE QUESTION IN MY VIDEO DOWN BELOW.

I HOPE THIS IS USEFUL AND HELPS YOU TO LEARN HOW TO SOLVE THOSE QUESTIONS.

THANK YOU FOR YOUR SUPPORT AND KUDOS TO NEW BEGINNINGS!!!!!!!!


IRA  6th dec Unix SBQ


Consider a file which stores the details of Bike. Fields in the file are

separated by colon(:)


ID:Name:Brand:RatingFY2021:RatingFY2122

101:Activa:Honda:4.5:4.7

102:Scooty:TVS:4.2:4.0

103:Apache:TVS:4.5:4.5

104:Bullet Enfield:4.6:4.5

105:Pulsar:Bajaj:4.3:4.2

106:Hayabusa:Suzuki:4 1:4.3

107:Dio: Honda:4.2:4.5


Write the unix command to print the top two records based on average

rating of bike where the records of only honda and TVS should be

considered. The output should display the ID, brand and average rating

separated by "|" in descending order of average rating of bike. (average

rating is calculated based on the columns, RatingFY2021 and

RatingFY2022). 

If the average rating are same for the top two records, then

the output are displayed in ascending order of ID.

Note: All searches should be case insensitive


Refer the example below for more clarity on input and output format. The

file name input will be provided as command line argument when the script

containing your command will run. You can use shell variables (eg.

$0,$1,$2) whichever is applicable for your requirement to provide the

command line argument.


Sample Input 1 :


ID:Name:Brand:RatingFY2021:Rating2122 

101:Activa:Honda:4.5:4.7

102:Scooty:TVS:4.2:4.0

103:Apache:TVS:4.5:4.5

104:Bullet Enfield:4.6:4.5

105:Pulsar:Bajaj:4.3:4.2

106:Hayabusa:Suzuki:4 1:4.3

107:Dio: Honda:4.2:4.5


Expected Output:

101|Activa|4.6

103|Apache|4.5



Sample Input 2


ID:Name:Brand:RatingFY2021:RatingFY2122

101:Activa:Honda:4.1:4.5

107:Scooty:TVS:4.2.4.3

105:Apache:TVS:4.5:4.2

104:Bullet:Enfield:4.6:4.5

106:Pulsar:Bajaj:4.3:4.2

106:Hayabusa:Suzuki:4.1:4.3

102:Dio:Honda:4.2:4.5


Expected Output: 


102 | Dio|4.35

105| Apache|4.35 


HOW TO SOLVE THE ABOVE SOLUTION:



IN THIS VIDEO ,I HAVE SHOWED HOW TO USE THE AWK COMMAND TO PERFORM OPERATION ON THE DATA AND ALSO SHOWED HOW TO CREATE DICT TYPE ARRAY TO STORE VALUES AS KEY_VALUE PAIR ALONG WITH CONVERTION OF UPPER CASE TO LOWER CASE.

CODE FOR YOUR REFERENCE:



THANK YOU SO MUCH FOR READING TILL NOW.I HOPE THIS WEBSITE IS USEFUL TO YOU TO PRACTICE.ALL THE BEST.!!!!!!!!!!







0 Comentarios

Follow Me On Instagram