Skip to content
Advertisement

How to get information from file with condition in Shell script without using “awk” [closed]

i have file

JavaScript

conditions : if the 2nd column is – then 2nd condition check last column value beginning in 4 then count the Name (William and John) Output :

JavaScript

Advertisement

Answer

Try:

JavaScript

Explanation: We are using if statement in awk to check the two conditions:

  • If 2nd element is equals to ‘-‘
  • If last element begins with 4

If above two conditions are true, we are printing name, stored in 3rd element

uniq -c will count occurrences of the names

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement