Add:
| sort -k 1nr,2
To the end of the UNIX command, i.e.
cut -d' ' -f3-4 | sort | uniq -c | sort -k 1nr,2
’-k 1nr’ says sort the first field numerically in reverse order, then sort on
the second field ‘2’
Again, “man sort” for more info.
--
Rod
> On Oct 8, 2020, at 6:54 AM, Howard <[email protected]> wrote:
>
> Rod,
>
> Your explanation is very helpful.
>
> Here is the result your code yields:
> 2 Apple Jones
> 1 Banana Herb
> 4 Harvey Haney
> 2 Sam Blue
>
> What if I want the output displayed like this: (How would I get that?)
> 4 Harvey Haney
> 2 Apple Jones
> 2 Sam Blue
> 1 Banana Herb
>
> Thus, the names are ordered by the number of times they appear, and if two or
> more names have the same number of occurrences, they are displayed in
> alphabetical order.
>
> Howard
> On Wednesday, 7 October 2020 at 11:12:30 pm UTC-4 Rod Buchanan wrote:
>
> -d’ ’ tells cut to use the space character as the column/field delimiter.
>
> -f3-4 tells it to only return columns/fields 3 and 4.
>
>
> From the man page. (Type “man cut” in Terminal.app for complete info.)
>
> cut -- cut out selected portions of each line of a file.
>
> SYNOPSIS
> cut -f list [-d delim] [-s] [file ...]
>
> DESCRIPTION
> The cut utility cuts out selected portions of each line (as specified by
> list)
> from each file and writes them to the standard output. If no file
> arguments are
> specified, or a file argument is a single dash (`-'), cut reads from the
> standard
> input. The items specified by list can be in terms of column position
> or in
> terms of fields delimited by a special character. Column numbering
> starts from
> 1.
>
> -d delim
> Use delim as the field delimiter character instead of the tab
> character.
>
> -f list
> The list specifies fields, separated in the input by the field
> delimiter
> character (see the -d option.) Output fields are separated by a
> single
> occurrence of the field delimiter character.
>
> --
> Rod
>
>
>> On Oct 7, 2020, at 11:03 AM, Howard <[email protected]
>> <applewebdata://CD626ED6-2CFE-4154-9D51-01EDABBA3C50>> wrote:
>>
>
>> Rod,
>>
>> What does the line below do?
>> cut -d' ' -f3-4
>>
>> Howard
>>
>> On Wednesday, 7 October 2020 at 10:11:31 am UTC-4 Rod Buchanan wrote:
>>
>> Click Text -> Run Unix Command… , then run this:
>>
>> cut -d' ' -f3-4 | sort | uniq -c
>>
>> When I copy/paste your data I get these results:
>>
>> 2 Apple Jones
>> 1 Banana Herb
>> 4 Harvey Haney
>> 2 Sam Blue
>>
>> --
>> Rod
>>
>>
>> --
>> Rod
>>
>>
>>> On Oct 6, 2020, at 1:23 PM, Howard <[email protected] <>> wrote:
>>>
>>
>>> I have the following data (shown below). I want to count how many times
>>> each of the four names appear (Harvey Haney, Apple Jones, Banana Herb, Sam
>>> Blue). Can this be done in BBEdit? If not, I would appreciate suggestions
>>> on how it can be done.
>>>
>>> 10:45:57 From Harvey Haney : Good morning. How is everyone today?
>>> 10:46:08 From Apple Jones : I'm doing good. How are you?
>>> 10:46:12 From Banana Herb : Good how are you!
>>> 10:46:18 From Sam Blue : I'm doing fine. How are you?
>>> 10:45:57 From Harvey Haney : Good morning. How is everyone today?
>>> 10:46:08 From Harvey Haney : I'm doing good. How are you?
>>> 10:46:12 From Apple Jones : Good how are you!
>>> 10:46:18 From Sam Blue : I'm doing fine. How are you?
>>> 10:45:57 From Harvey Haney : Good morning.
>>>
>>
>>> --
>>> This is the BBEdit Talk public discussion group. If you have a feature
>>> request or need technical support, please email "[email protected] <>"
>>> rather than posting here. Follow @bbedit on Twitter:
>>> <https://twitter.com/bbedit <https://twitter.com/bbedit>>
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "BBEdit Talk" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected] <>.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/bbedit/379b202c-463e-4d7c-8a26-af63ab83d0aan%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/bbedit/379b202c-463e-4d7c-8a26-af63ab83d0aan%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>
>>
>> --
>> This is the BBEdit Talk public discussion group. If you have a feature
>> request or need technical support, please email "[email protected]
>> <applewebdata://CD626ED6-2CFE-4154-9D51-01EDABBA3C50>" rather than posting
>> here. Follow @bbedit on Twitter: <https://twitter.com/bbedit
>> <https://twitter.com/bbedit>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "BBEdit Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected]
>> <applewebdata://CD626ED6-2CFE-4154-9D51-01EDABBA3C50>.
>
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/bbedit/83b7baf3-4b7a-4c49-8e5a-697b57795215n%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/bbedit/83b7baf3-4b7a-4c49-8e5a-697b57795215n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
>
> --
> This is the BBEdit Talk public discussion group. If you have a feature
> request or need technical support, please email "[email protected]"
> rather than posting here. Follow @bbedit on Twitter:
> <https://twitter.com/bbedit <https://twitter.com/bbedit>>
> ---
> You received this message because you are subscribed to the Google Groups
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/c95dc515-429d-4ccb-9107-2050e1e38e28n%40googlegroups.com
>
> <https://groups.google.com/d/msgid/bbedit/c95dc515-429d-4ccb-9107-2050e1e38e28n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
This is the BBEdit Talk public discussion group. If you have a feature request
or need technical support, please email "[email protected]" rather than
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/BC896B6B-6FFF-4EF4-A983-E4D6B6606DCC%40sofstats.com.