HELLO DORAEMONS,
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
0 Comentarios