jeudi 26 mars 2015

can we get sorted grep output


I have same: 1.txt with apple written in it, 2.txt with mango written in it, 3.txt with apple written in it, 4.txt with mango written in it.


grep -e apple -e mango *.txt will give result as:



1.txt: apple
2.txt: mango
3.txt: apple
4.txt: mango


But I need output as:



1.txt: apple
3.txt: apple
2.txt: mango
4.txt: mango


Is it possible with just grep command ? -- without using any other command like sort or so



Aucun commentaire:

Enregistrer un commentaire