If you see at the output closely, there is a column name "robot#" with values as [0,1,-]. All I want to do is to grep all rows with "robot# 0" and get the total count for it with "wc -l".
Don's command is exactly what I was looking for. Would appreciate if this can be explained a bit further that What C++ is used for ? Why $4==0 what does END being used for ? Thanks you.
awk '$4==0 ##### It is a condition check(similar what we do in if else condition check). Where $4 means 4th field and we are checking here if 4th field is 0 or not.
{
c++ ##### If 4th field is having ZERO value then there is variable named C, so we are incrementing it's value by doing c++ to one.
}
END{ ##### Here starts END block, in awk there are 3 sections, i- BEGIN- if you want to perform some operations in very starting of your program. ii- Body- where we write actual logic/code for our requirements. iii- END- block code will be executed when all Inputs are read from Input_file.
print c}' ##### printing the value of variable c, which will tell us how many 4th fields have value 0 in them.
That is great. Thank you very much. I miss-understood C++ with the tool C++.. So its just that I can use any variable to put in the value and increment it till I find my results.
Worked perfectly how I needed it. Thank you both. I will now close this thread.
Regards,
A.s
---------- Post updated at 03:18 PM ---------- Previous update was at 03:10 PM ----------
Your Welcome Ali, for making threads solved. You should navigate to right most up corner of the page and click on EDIT TAGS and add solve there, in order to make a thread as solved. I will do it for you on this thread, you could explore that option though.