I am using grep command to take the required information from a file . I am using two grep statements like the below
XXXX='grep XXXX FILE A|sort|uniq|wc -l'
grep YYYY FILE A|uniq| > FILE B
Now the file is being traversed twice . But I just want to know, if I will be able to do these two steps in a single file traversal i.e I want to know if I could use something similar to egrep where I can grep for two strings and one string I will use it for stroring in a variable and output of another string into a file.