Skip to content

Instantly share code, notes, and snippets.

@JohnL4
Last active September 30, 2020 15:01
Show Gist options
  • Save JohnL4/4e52c56c641c8468bfd76b3579d88203 to your computer and use it in GitHub Desktop.
Save JohnL4/4e52c56c641c8468bfd76b3579d88203 to your computer and use it in GitHub Desktop.
grep | sort | uniq in PowerShell vs. Unix

PowerShell:

cat Temp\dashboard-plus-reset-filters-to-default-plus-turn-off-one-cascading-filter.json `
  | Select-String '"count": [0-9]+' `
  | select -expand Matches `
  | % {$_.Value} `
  | sort `
  | gu

Unix:

cat Temp/dashboard-plus-reset-filters-to-default-plus-turn-off-one-cascading-filter.json \
  | egrep -i '"Count": [0-9]+' \
  | sed -e's/^[     ]//' \
  | sort \
  | uniq --count

I still like Unix (bash) better for this sort of thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment