New answers tagged

1

sort -t_ -k2 infile will sort data using the 2nd key with underscore as separator.


0

The program you're looking that can easily do what you want is called awk. :-) It can do programmed actions on matched RE patterns. Untested, simplified, rote, example awk program that should work with your example input and specified patterns: BEGIN { eights = 0; fives = 0; threes = 0; } /8888/ { eightln[eights] = $0; eights++; } ...


-1

Nautilus used to have these options : View >> Arrange Items >>> 1 Manually 2 By Name 3 By Type 4 By Modification Date 5 By Emblems Suggest "By Name", then it should be alphabetical order.


0

On GNU system: $ NL=' ' $ <file xargs -n4 -d "$NL" sh -c 'printf "%s\n" "$@" | sort' sh world1.com /randomkeygahjuh572/key639839 world2.com /randomkey788gauh72/key63whjk world3.com /randomkey788gauh72/key63whjk world4.com /randomkeyhghgdh778/key67567 world1.com /randomkeyhueh34778/key67uuu77 world2.com ...


1

$ awk '{l=l+1; ln[$1]=$0; if (l%4==0) { \ printf ("%s\n%s\n%s\n%s\n", ln["world1.com"], ln["world2.com"], ln["world3.com"], ln["world4.com"]); \ delete ln; l=0; } } ' test.txt world1.com /randomkeygahjuh572/key639839 world2.com /randomkey788gauh72/key63whjk world3.com /randomkey788gauh72/key63whjk world4.com ...


1

#!/usr/bin/perl use strict; use warnings; use autodie; use open qw< :encoding(ASCII) >; my $filename = $ARGV[0]; my ($ip_fh, $op_fh); open($ip_fh, "<", $filename); open($op_fh, ">", "$filename".".sorted"); my @ip_lines = <$ip_fh>; for(my $i = 0; $i <= $#ip_lines; $i++) { print $op_fh sort @ip_lines[$i..($i+3)]; $i += 3; } ...


1

This perl script should work with any number of domains (first fields) with any number of keys (second fields) per domain. Domains may have the same number of keys each, but don't have to. It builds up a hash (%domains) with each element of the hash containing an array of keys. While doing that, it keeps track of the largest number of keys seen for any of ...


5

To organize the files by world: $ paste -d'\n' <(grep world1 file) <(grep world2 file) <(grep world3 file) <(grep world4 file) world1.com /randomkeygahjuh572/key639839 world2.com /randomkey788gauh72/key63whjk world3.com /randomkey788gauh72/key63whjk world4.com /randomkeyhghgdh778/key67567 world1.com ...


1

I cannot speak for vendor specific implementations, but the UNIX sort implementation splits large files into smaller files, sorts these files and then combines the sorted smaller files into an aggregated sorted output. The only limitation is the disk space for the smaller files created intermediately by sort, but the files can be redirected to an arbitrary ...


36

The sort that you find on Linux comes from the coreutils package and implements an External R-Way merge. It splits up the data into chunks that it can handle in memory, stores them on disc and then merges them. The chunks are done in parallel, if the machine has the processors for that. So if there was to be a limit, it is the free disc space that sort can ...


0

Based on https://blog.mafr.de/2010/05/23/sorting-large-files/ and http://unix.stackexchange.com/a/88704/9689 : split -n l/20 input input- for inpf in input-* ; do sort --parallel="$(nproc --all)" "${inpf}" > sorted-"{$inpf}" done sort -m sorted-input-* > sorted-input Update: From answers above we see that sort already does what mentioned ...



Top 50 recent answers are included