Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Limits on file numbers in sort -m
- Date: Fri, 30 May 2014 09:43:14 +0900
- From: Travis Cardwell <travis.cardwell@example.com>
- Subject: Re: [tlug] Limits on file numbers in sort -m
- References: <CABHGxq7jYkDDLkF8uzzNK8WeU+37t1wgpVhk6VD2HQKyEi7wBw@mail.gmail.com> <CAJMSLH618MfmhL9ufAOfLXxw52i4STpF8dsc_+xe-2GRB3JM8g@mail.gmail.com> <87bnui8sky.fsf@uwakimon.sk.tsukuba.ac.jp> <CABHGxq4NEBMVR8jndiEvcgsGkc_B0f-qcrs2sFjqaAdWH3n9sw@mail.gmail.com> <CAJMSLH6SdSUmvHsjmZBZP-g1graNuPV51vdwLzpPf7ipmz7+zA@mail.gmail.com> <CABHGxq7eCk9Pk1JtNrZuqK_8yv4bt7ftoWwyXqf5P+GKYQH=5w@mail.gmail.com> <87sins7mhy.fsf@uwakimon.sk.tsukuba.ac.jp> <CAJA1Y2b6XyFNsFhDbK+ktgWk0cE5Lzfv9OrhimBH8RyN78yzLQ@mail.gmail.com> <87d2ew76yd.fsf@uwakimon.sk.tsukuba.ac.jp> <CAJA1Y2Y2vaH06nJyt25uREjCT9RELoTnfwDpeXX5Z97W45oZUQ@mail.gmail.com>
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0
On 2014年05月30日 05:21, Bruno Raoult wrote: > So "uniq *" was able to read files, but "sort -m *" was not, right? > And a "uniq | sort | uniq" is not possible??? > > I am stupid, I dont understand the issue at all :-(, and I would like > to understand clearly, with output of commands if possible... I can be very specific using types... A strongly-typed sort command would take a list of orderable elements and return a list of the same (but in sorted order): sort :: Ord a => [a] -> [a] A strongly-typed uniq command (as used) would take a (sorted) list of elements which can be compared for equality and return a list of elements with associated counts: uniq :: Eq a => [a] -> [(a, Int)] In a strongly-typed shell, `uniq | sort` (`sort . uniq` in function composition syntax) would have type: (sort . unq) :: (Eq a, Ord a) => [a] -> [(a, Int)] `uniq | sort | uniq` would therefore have type: (uniq . sort . uniq) :: (Eq a, Ord a) => [a] -> [((a, Int), Int)] As you can see from the return value ([((a, Int), Int)]), the result is a list of element+count pairs (from the first uniq) with associated counts (from the second uniq). Our shell is not strongly-typed, but the result is essentially the same when passing around strings. It does not meet the requirements. [1] What is needed is a command that sums the counts of equal elements when merging. In the style of a merge sort: merge :: Eq a => [(a, Int)] -> [(a, Int)] -> [(a, Int)] The `sort -m` command does not sum counts, which is why Jim said that he will need to use external software to do so. Cheers, Travis [1] Check the output of the following commands: $ sort -R /usr/share/dict/words | head -n 30000 | sort > words.1 $ sort -R /usr/share/dict/words | head -n 30000 | sort > words.2 $ sort -R /usr/share/dict/words | head -n 30000 | sort > words.3 $ sort -R /usr/share/dict/words | head -n 30000 | sort > words.4 $ sort -m words.1 words.2 | uniq -c > words.12 $ sort -m words.3 words.4 | uniq -c > words.34 $ sort -m words.12 words.34 | uniq -c > words.1234
- Follow-Ups:
- Re: [tlug] Limits on file numbers in sort -m
- From: Jim Breen
- Re: [tlug] Limits on file numbers in sort -m
- From: Josh Glover
- Re: [tlug] Limits on file numbers in sort -m
- From: Stephen J. Turnbull
- References:
- [tlug] Limits on file numbers in sort -m
- From: Jim Breen
- Re: [tlug] Limits on file numbers in sort -m
- From: 黒鉄章
- Re: [tlug] Limits on file numbers in sort -m
- From: Stephen J. Turnbull
- Re: [tlug] Limits on file numbers in sort -m
- From: Jim Breen
- Re: [tlug] Limits on file numbers in sort -m
- From: 黒鉄章
- Re: [tlug] Limits on file numbers in sort -m
- From: Jim Breen
- Re: [tlug] Limits on file numbers in sort -m
- From: Stephen J. Turnbull
- Re: [tlug] Limits on file numbers in sort -m
- From: Bruno Raoult
- Re: [tlug] Limits on file numbers in sort -m
- From: Stephen J. Turnbull
- Re: [tlug] Limits on file numbers in sort -m
- From: Bruno Raoult
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Limits on file numbers in sort -m
- Next by Date: Re: [tlug] Limits on file numbers in sort -m
- Previous by thread: Re: [tlug] Limits on file numbers in sort -m
- Next by thread: Re: [tlug] Limits on file numbers in sort -m
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links