You are on page 1of 1

Create the below input file ABC

ItemName|MAxCount|MinCount|Location|InCharge
Notepad|500|50|PP|Akhil
Marker|100|20|CLC|Ajith
Pen|700|10|PP|Akhil
Pencil|500|30|CLC|Vinay
Eraser|200|25|PP|Ajith
StickyNotes|400|15|PP|Vinay
Notepad|300|5|CLC|Vinay

ANS :-

1. Find the average number of Max notepads required at PP and CLC?

[u1352325@INTVMAO01 ~]$ awk -F '|' '$1 == "Notepad"' FILE4 |awk -F '|' '{total+=$2}
END{print total/NR}'
400

2. Write a command to sort the items in the increasing order of minimum count

[u1352325@INTVMAO01 ~]$ sed -n '2,8p' FILE4|sort -t '|' -k 3 -n


Notepad|300|5|CLC|Vinay
Pen|700|10|PP|Akhil
StickyNotes|400|15|PP|Vinay
Marker|100|20|CLC|Ajith
Eraser|200|25|PP|Ajith
Pencil|500|30|CLC|Vinay

3. What all items are managed by Vinay?

[u1352325@INTVMAO01 ~]$ awk -F '|' '$5 == "Vinay"' FILE4 |awk -F '|' '{print $1}'
Pencil
StickyNotes
Notepad

4. What is the minimum count of pen to be kept?

[u1352325@INTVMAO01 ~]$ awk -F '|' '$1 == "Pen"' FILE4 |awk -F '|' '{print $3}'
10

You might also like