TCS IRA UNIX 21 MARCH 2022

HELLO DORAEMONS,

IN THIS BLOGPOST ,I HAVE SHARED THE RECENTLY ASKED UNIX/BASH QUESTION AND SOLUTION WHICH IS CERTAINLY USEFUL WHEN YOU WANT TO PRACTICE.HOPE THIS BLOG IS USEFUL TO YOU.

Rajesh is playing a game and he is stuck at a point.

Few lines having a list of numbers separated by comma are given to him and he must create the number possible by considering the comma separated numbers from each line as digits of the number and find the greatest of all the numbers created.

Now your task is to help him in creating the numbers that can be formed from the list of comma separated numbers in each line and choose the greatest among all such newly created numbers.

Condition: Every line contains a list of numbers separated by","and you need to create the numbers that can be formed from that list of comma separated numbers for each line and finally, you need to print the greatest from all the numbers. (For more clarity see the sample input and output format along with explanation)

Write a Unix command that prints the greatest number that satisfies the above condition,

Input: Few lines having a list of numbers separated by", 

Output: print the greatest number


Sample Input :


3,0,4,5,9

2,1,5,9

1,2,3,4,5


Expected output:


30459


Explanation :

The first line contains a list of comma separated numbers that is 3,0,4,5,9. So the number that can be

formed from the above list of numbers is 30459.

Similarly, for the second list, the number that is formed is 2159 and from the 3rd list of numbers, the

number that is formed is 12345.

And at the end print the greatest among all the numbers. i.e. The greatest number among 30459,2159

and 12345. Hence our output will be 30459.

1 Refer to the examples below for more clarity on input and output formats.

2 The file name input will be provided as a command-line argument when the script containing your

command will run.

You can use shell variables (e.g. $0,$1,$2) whichever applies to your requirement to providing the

command line argument.


Sample Input 1:


3,0,4,5,9

2,1,5,9

1,2,3,4,5

0,0,0,0,9

9,9,9,9,9


Expected output:


99999


Sample Input:


0,0,0,0


Expected output:


0

HOPE THIS IS HELPFUL TO YOU GUYS.IF YOU LIKE MY WORK ,CONSIDER SUBSCRIBING TO MY CHANNEL AND FOLLOW MY BLOGPOST FOR MORE UPDATES.


1 Comentarios

Follow Me On Instagram