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!!!!!!!!
1. IRA SBQ 1st Nov UNIX Contents of input file: Booking ALL
PNR NO ; Date Of Travel; No Of Passengers ; Total Amount ; Destination
1;10-Mar-21;2;4000; Mumbai
2,12-May-21;1;3000;Bangalore
3;13-May-21,3;6500;Srinagar
4;11-Feb-21;1;18000;Andaman
5;27-Oct-21;2;10000;Mumbai
6;30-Oct-21:4;8750;Ahmedabad
Fields are separated by the field separator (";")
Write a command to display the month when maximum amount was collected .
Display the month(in UPPER case) and the total amount separated with a space.
For more clarity, please refer to the sample input and output below .
Consider that no two months will have same total amount.
Note: Ignore the case sensitivity for string values.
The input file with the data(testcase input/customized input) in the format mentioned,
automatically supplied as command line argument when you run the script/command you have
written. Hence you don't need to worry / work on, "How to bring the file to your script"?.
You just need to assume that a file is supplied to your script and read the file, which is supplied as
command line argument and process the data in the file towards the given requirement.
You can use shell variables (e.g. $0,$1,$2) whichever is applicable for your requirement to provide the
command line argument.
Sample Input 1:
PNR No ; Date Of Travel ; No Of Passengers ; Total Amount ; Destination
1:10-mar-21;2;4000;Mumbai
2;12-May-21;1;3000;Bangalore
3;13-May-21,3;6500;Srinagar
4;11-feb-21;1;1850;Andaman
5;27-Oct-21,2,10000; Mumbai
6;30-Oct-21;4;8750;Ahmedabad
Output:
OCT 18750
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.!!!!!!!!!!
10th jan unix solution:
1 Comentarios
tr "-" ";"| tr ";" " " |sort -nk6 | tail -n1 | awk 'BEGIN{}{print $3, $6}'|
ReplyDeletetr [:lower:] [:upper:]