New answers tagged

2

You can use clickhouse-client tool for working with files like with a sql table with a single column in this case: clickhouse-local --query \ "select data, count() from file('access.log', TSV, 'data String') group by data order by count(*) desc limit 10" My brief experiment shows it's about 50 times faster than cat access.log | sort | uniq -c | ...


0

-kx,y means: use the section of the line that starts with the start of the xth field and ends at the end of the yth field as the sort key. So -k3,2 does not make sense in that context. If you mean: sort numerically on the third fied, and then on the second field, that would be: sort -nt_ -k3,3 -k2,2 Or: sort -t_ -k3,3n -k2,2n (here with the numeric flag ...


5

It's kinda difficult to tell what you're trying to accomplish, but I'm assuming you need: 5_5_1_2 5_5_1_3 5_5_1_4 5_5_1_5 5_5_2 5_5_3 5_5_4 5_5_5 5_6 5_7 6_1_2 6_1_3 6_1_4 6_1_5 6_1_6 6_1_7 6_1_8 6_1_9 6_1_10 6_1_11 6_1_12 6_1_13 6_1_14 6_2_1 6_2_2 6_2_3 6_2_10 6_2_11 6_2_12 6_2_13 6_2_14 6_2_15 6_2_16 6_2_17 as output. This can be obtained, by regarding ...


1

If you know how many fields you have: $ sort -t, -k7,7n file XYZ,JKL,MNO,3,-5,0.2,-0.342 STU,WXY,DEF,-1,4,0.01,0.345 ABC,DEF,GHI,-5,-8,-0.6,0.488 or if you don't: $ awk 'BEGIN{FS=OFS=","} {print $NF,$0}' file | sort -t, -k1,1n | cut -d, -f2- XYZ,JKL,MNO,3,-5,0.2,-0.342 STU,WXY,DEF,-1,4,0.01,0.345 ABC,DEF,GHI,-5,-8,-0.6,0.488 and to sort by the ...


0

Assuming the input is relatively simple (delimiter does not appear in the records) you can sort by a given column like this: $ c=$(< input awk -F, 'NR==1 { print NF; exit }') $ < input sort -t, -k $c,${c}n --debug output: XYZ,JKL,MNO,3,-5,0.2,-0.342 ______ ___________________________ STU,WXY,DEF,-1,4,0.01,0.345 ...


0

Using the R-programming language The two data files are read into the R REPL: > john <- read.csv("/Users/admin/john", header=FALSE, stringsAsFactors=FALSE) > jane <- read.csv("/Users/admin/jane", header=FALSE, stringsAsFactors=FALSE) > head(john) V1 V2 1 apple green 2 cherry red 3 orange orange > head(jane)...


1

Using the R-programming language Text files were saved and one-or-more space characters were replaced with single tabs. The two data files were read into R: > group0 <- read.delim("/Users/admin/bygroup.0", header=FALSE) > group2 <- read.delim("/Users/admin/bygroup.2", header=FALSE) > head(group0) V1 V2 ...


0

Frequency of strings easy: grep -c 'your_string' your_file Or even faster if you have ripgrep: rg -c 'your_string' your_file


1

TXR Lisp solution: $ txr merge.tl ancient-american mercury 1 164 ancient-american mercury 1 160 ancient-american mh25 2 8717664 ancient-american mh25 2 10362712888 ancient-neolith tk11 262 40074321970 ancient-neolith tk11 264 43842268110 ancientdna jk21 6936 17069206689 ancientdna jk21 6919 16379509855 ...


Top 50 recent answers are included