New answers tagged

0 votes

Can I find all files with the .log extension and order by file size?

With zsh: zmodload zsh/stat stat -n +size -- **/*.log(DN-.oL)
Stéphane Chazelas's user avatar
0 votes

Trying to sort on two fields, second then first

Using Raku (formerly known as Perl_6) Adding this answer for U&L users who might be trying to sorting Unicode. Raku has high-level support for Unicode built-in, and this answer (in part) is to ...
jubilatious1's user avatar
  • 3,050
2 votes

awk: sort by first column then second; output unique 1st column once but all 2nd column

Using Raku (formerly known as Perl_6) ~$ raku -ne 'BEGIN my %h; %h.append: .split(/ \s+ /); END put .key => .value.sort.join("\n\t") for %h.sort;' file #OR ~$ raku -ne 'BEGIN my %h; ...
jubilatious1's user avatar
  • 3,050
7 votes
Accepted

awk: sort by first column then second; output unique 1st column once but all 2nd column

One awk idea: awk ' BEGIN { OFS="\t" } { a[$1][$2] } # we can sort on both indices to obtain the desired ordering END { PROCINFO["sorted_in"] ...
markp-fuso's user avatar
9 votes

awk: sort by first column then second; output unique 1st column once but all 2nd column

Original awk solution removed - a better solution has been posted Pragmatically, you could pre-sort the input and just use (any) awk to format it: sort twocol | awk 'BEGIN{OFS="\t"} {print $...
steeldriver's user avatar
  • 80.8k
-1 votes

What should be the buffer size for the sort command?

It is hard to believe, but you souldn't use gnu sort for large files at all. I've noticed it long ago, that sort and sort -u have terrible performance, despite being written in C. If you are not ...
Oleg Gritsak's user avatar

Top 50 recent answers are included