TCS IRA UNIX 14TH 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.

Consider below input file:

leaveid,leavetype, Approved,DOAP 

 1,CL,yes, 11-Jan-22

 2,CL, no, 21-Mar-22

 3,SL, Yes, 28-Feb-22

 4,EL, NO,22-Jun-22 

 5,SL, Yes, 15-Sep-22 

 6,CL, Yes, 16-Nov-22

Fields are separated by the field separator (",")

Write a command to display the leaveid, leavetype, month for the approved leaves(Approved= 'Yes'). Month field should be extracted from DOAp(date of application).

Display the output fields separated with a ":".

If there are no approved leaves, print a message "no data found" (excluding quotes)

For more clarity, please refer to the sample input and output below.

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:

leaveid, leavetype, Approved,DOAP 

1,CL,yes,11-Jan-22 

2,CL,no,21-Mar-22 

3,SL,Yes,28-Feb-22 

4,EL,NO,22-Jun-22 

5, SL,Yes,15-Sep-22 

6,CL,Yes,16-Nov-22


Output:

1:CL:Jan 

3:SL:Feb 

5:SL:Sep 

6:CL:Nov

Sample Input 2:

leaveid,leavetype, Approved,DOAP 

1,CL, no, 11-Jan-22 

2,CL,no, 21-Mar-22 

3,SL,No,28-Feb-22

Output:

no data found


SOLUTION VIDEO FOR THIS QUESTION:




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

0 Comentarios

Follow Me On Instagram