1

In Powershell, you can parse a csv file for example, and use the command group-objects to get basic stats such as the number of records for particular items etc..

I was wondering if there's a quick trick in bash to do roughly the same and group objects by a certain field ? (I am thinking it could be possible using awk, but I've not find anything helpful).

I am not looking for any perl/python answer, I really need bash :)

Thank you!

Bluz
  • 5,980
  • 11
  • 32
  • 40
  • I'm going to hold off on marking this as a dupe because my bash knowledge is not up to the task of evaluating the usefulness of the answers and I don't have access to a system to test on right now but I think this is what you need:https://stackoverflow.com/questions/380817/best-way-to-simulate-group-by-from-bash – EBGreen Jun 15 '18 at 16:17
  • 1
    bash is stringly-typed so there isn't that same object-oriented feel that `Group-Object` has; you're always just manipulating strings. – Maximilian Burszley Jun 15 '18 at 17:00
  • @EBGreen - Terrific, thanks! I think the solution proposed on that other thread: grep -ioh "facebook\|xing\|linkedin\|googleplus" access-log.txt | sort | uniq -c | sort -n is exactly what I am looking for! thanks! – Bluz Jun 15 '18 at 17:18

0 Answers0