我正在寻找一个命令,它将接受(作为输入)多行文本,每行包含一个整数,并输出这些整数的和。

作为一点背景知识,我有一个日志文件,其中包括计时测量。通过grepping的相关行和一点sed重新格式化,我可以列出该文件中的所有时间。我想算出总数。我可以将这个中间输出输出到任何命令,以便进行最终求和。我过去一直使用expr,但除非它在RPN模式下运行,否则我不认为它会处理这个问题(即使这样也会很棘手)。

我怎样才能得到整数的和?


perl -lne '$x += $_; END { print $x; }' < infile.txt

一点awk就行了?

awk '{s+=$1} END {print s}' mydatafile

注意:如果要添加超过2^31(2147483647)的值,某些版本的awk会有一些奇怪的行为。查看评论了解更多背景信息。一个建议是使用printf而不是print:

awk '{s+=$1} END {printf "%.0f", s}' mydatafile

你可以在python中这样做,如果你觉得舒服的话:

没有测试,只是输入:

out = open("filename").read();
lines = out.split('\n')
ints = map(int, lines)
s = sum(ints)
print s

Sebastian指出了一个单行脚本:

cat filename | python -c"from fileinput import input; print sum(map(int, input()))"

一个简单的解决方案是编写一个程序来为你做这件事。这可能在python中很快就可以完成,类似于:

sum = 0
file = open("numbers.txt","R")
for line in file.readlines(): sum+=int(line)
file.close()
print sum

我还没有测试该代码,但它看起来是正确的。只需将numbers.txt更改为文件名,将代码保存到一个名为sum.py的文件中,并在控制台中键入"python sum.py"


bash的工作原理如下:

I=0

for N in `cat numbers.txt`
do
    I=`expr $I + $N`
done

echo $I

Python中的一行代码版本:

$ python -c "import sys; print(sum(int(l) for l in sys.stdin))"

BASH解决方案,如果你想让它成为一个命令(例如,如果你需要经常这样做):

addnums () {
  local total=0
  while read val; do
    (( total += val ))
  done
  echo $total
}

然后使用:

addnums < /tmp/nums

普通的bash:

$ cat numbers.txt 
1
2
3
4
5
6
7
8
9
10
$ sum=0; while read num; do ((sum += num)); done < numbers.txt; echo $sum
55

以下操作应该可以工作(假设您的数字是每行上的第二个字段)。

awk 'BEGIN {sum=0} \
 {sum=sum + $2} \
END {print "tot:", sum}' Yourinputfile.txt

您可以使用num-utils,尽管对于您所需要的来说它可能太过了。这是一组用于在shell中操作数字的程序,可以做一些漂亮的事情,当然包括将它们相加。它有点过时了,但它们仍然有效,如果你需要做更多的事情,它们可以很有用。

https://suso.suso.org/programs/num-utils/index.phtml

使用起来非常简单:

$ seq 10 | numsum
55

但内存不足,无法输入大量数据。

$ seq 100000000 | numsum
Terminado (killed)

粘贴通常合并多个文件的行,但它也可以用于将文件的各个行转换为一行。分隔符标志允许您将x+x类型的方程传递给bc。

paste -s -d+ infile | bc

或者,当从stdin管道时,

<commands> | paste -s -d+ - | bc

dc -f infile -e '[+z1<r]srz1<rp'

注意,带负号前缀的负数应该转换为dc,因为它使用_ prefix而不是- prefix。例如,通过tr '-' '_' | dc -f- -e '…'。

编辑:由于这个答案获得了很多“晦涩难懂”的投票,下面是一个详细的解释:

表达式[+z1<r]srz1<rp的作用如下:

[   interpret everything to the next ] as a string
  +   push two values off the stack, add them and push the result
  z   push the current stack depth
  1   push one
  <r  pop two values and execute register r if the original top-of-stack (1)
      is smaller
]   end of the string, will push the whole thing to the stack
sr  pop a value (the string above) and store it in register r
z   push the current stack depth again
1   push 1
<r  pop two values and execute register r if the original top-of-stack (1)
    is smaller
p   print the current top-of-stack

伪代码:

定义"add_top_of_stack"为: 从堆栈中删除顶部的两个值,并将结果添加回来 如果堆栈有两个或两个以上的值,递归地运行"add_top_of_stack" 如果堆栈有两个或两个以上的值,执行"add_top_of_stack" 打印结果,现在堆栈中只剩下一项

为了真正理解dc的简单和强大,这里有一个工作的Python脚本,它实现了dc的一些命令,并执行上述命令的Python版本:

### Implement some commands from dc
registers = {'r': None}
stack = []
def add():
    stack.append(stack.pop() + stack.pop())
def z():
    stack.append(len(stack))
def less(reg):
    if stack.pop() < stack.pop():
        registers[reg]()
def store(reg):
    registers[reg] = stack.pop()
def p():
    print stack[-1]

### Python version of the dc command above

# The equivalent to -f: read a file and push every line to the stack
import fileinput
for line in fileinput.input():
    stack.append(int(line.strip()))

def cmd():
    add()
    z()
    stack.append(1)
    less('r')

stack.append(cmd)
store('r')
z()
stack.append(1)
less('r')
p()

sed 's/^/.+/' infile | bc | tail -1

我知道这是一个老问题,但我很喜欢这个解决方案,愿意与大家分享。

% cat > numbers.txt
1 
2 
3 
4 
5
^D
% cat numbers.txt | perl -lpe '$c+=$_}{$_=$c'
15

如果有兴趣,我将解释它是如何工作的。


$ cat n
2
4
2
7
8
9
$ perl -MList::Util -le 'print List::Util::sum(<>)' < n
32

或者,你可以在命令行输入数字:

$ perl -MList::Util -le 'print List::Util::sum(<>)'
1
3
5
^D
9

但是,这种方法会占用文件,因此不适合用于大文件。请参阅j_random_hacker的答案,以避免吮吸。


简单的bash一行

$ cat > /tmp/test
1 
2 
3 
4 
5
^D

$ echo $(( $(cat /tmp/test | tr "\n" "+" ) 0 ))

c++(简体):

echo {1..10} | scc 'WRL n+=$0; n'

SCC项目- http://volnitsky.com/project/scc/

SCC是shell提示符下的c++代码段求值器


提前为反勾号(“'”)的可读性道歉,但这些在shell中工作,而不是bash,因此更易于粘贴。如果你使用一个接受它的shell, $(command…)格式比' command…所以为了你的理智,请随意修改。

我在bashrc中有一个简单的函数,它将使用awk来计算一些简单的数学项

calc(){
  awk 'BEGIN{print '"$@"' }'
}

这将做 +,-,*,/,^,%, √6,罪恶,因为,括号……(取决于你的awk版本)…你甚至可以用printf和格式化浮点输出,但这是我通常需要的

对于这个特定的问题,我将对每一行简单地这样做:

calc `echo "$@"|tr " " "+"`

所以对每一行求和的代码块看起来像这样:

while read LINE || [ "$LINE" ]; do
  calc `echo "$LINE"|tr " " "+"` #you may want to filter out some lines with a case statement here
done

如果你想逐行求和的话。但是,对于数据文件中的每个数字的总数

VARS=`<datafile`
calc `echo ${VARS// /+}`

顺便说一句,如果我需要在桌面上快速做一些事情,我使用这个:

xcalc() { 
  A=`calc "$@"`
  A=`Xdialog --stdout --inputbox "Simple calculator" 0 0 $A`
  [ $A ] && xcalc $A
}

纯粹的bash,在一行代码中:-)

$ cat numbers.txt
1
2
3
4
5
6
7
8
9
10


$ I=0; for N in $(cat numbers.txt); do I=$(($I + $N)); done; echo $I
55

《球拍》中的一句俏皮话:

racket -e '(define (g) (define i (read)) (if (eof-object? i) empty (cons i (g)))) (foldr + 0 (g))' < numlist.txt

纯粹而简短的敲打。

f=$(cat numbers.txt)
echo $(( ${f//$'\n'/+} ))

C(未简化)

seq 1 10 | tcc -run <(cat << EOF
#include <stdio.h>
int main(int argc, char** argv) {
    int sum = 0;
    int i = 0;
    while(scanf("%d", &i) == 1) {
        sum = sum + i;
    }
    printf("%d\n", sum);
    return 0;
}
EOF)

所有基于fedora的系统[fedora,RHEL,CentOS,korora等]上都有lua解释器,因为它嵌入了rpm-package(包管理器rpm的包),即rpm-lua],如果你想学习lua,这种问题是理想的(你也会完成你的工作)。

cat filname | lua -e "sum = 0;for i in io.lines() do sum=sum+i end print(sum)"

这很有效。虽然Lua很啰嗦,但你可能不得不忍受一些反复敲击键盘的伤害:)


#include <iostream>

int main()
{
    double x = 0, total = 0;
    while (std::cin >> x)
        total += x;
    if (!std::cin.eof())
        return 1;
    std::cout << x << '\n';
}

...和PHP版本,只是为了完整起见

cat /file/with/numbers | php -r '$s = 0; while (true) { $e = fgets(STDIN); if (false === $e) break; $s += $e; } echo $s;'

我的15美分:

$ cat file.txt | xargs  | sed -e 's/\ /+/g' | bc

例子:

$ cat text
1
2
3
3
4
5
6
78
9
0
1
2
3
4
576
7
4444
$ cat text | xargs  | sed -e 's/\ /+/g' | bc 
5148

Rebol中的一句话:

rebol -q --do 's: 0 while [d: input] [s: s + to-integer d] print s' < infile.txt

不幸的是,上述在Rebol 3中还不能工作(INPUT不能流化STDIN)。

下面是一个在Rebol 3中也适用的临时解决方案:

rebol -q --do 's: 0 foreach n to-block read %infile.txt [s: s + n] print s'

简单的php

  cat numbers.txt | php -r "echo array_sum(explode(PHP_EOL, stream_get_contents(STDIN)));"

实时求和,让您监视某些数字处理任务的进度。

$ cat numbers.txt 
1
2
3
4
5
6
7
8
9
10

$ cat numbers.txt | while read new; do total=$(($total + $new)); echo $total; done
1
3
6
10
15
21
28
36
45
55

(在这种情况下,不需要将$total设置为0。你也不能在完成后访问$total。)


我的版本:

seq -5 10 | xargs printf "- - %s" | xargs  | bc

我会在普遍认可的解决方案上加上一个大大的警告:

awk '{s+=$1} END {print s}' mydatafile # DO NOT USE THIS!!

这是因为在这种形式中,awk使用32位有符号整数表示:当和超过2147483647(即2^31)时,它将溢出。

更一般的答案(对于整数求和)是:

awk '{s+=$1} END {printf "%.0f\n", s}' mydatafile # USE THIS INSTEAD

金桥:

seq 10 | jq -s 'add' # 'add' is equivalent to 'reduce .[] as $item (0; . + $item)'

您可以使用Alacon -命令行实用程序为Alasql数据库。

它与Node.js一起工作,所以你需要安装Node.js,然后安装Alasql包:

要从stdin中计算sum,可以使用以下命令:

> cat data.txt | node alacon "SELECT VALUE SUM([0]) FROM TXT()" >b.txt

替代纯Perl,相当可读,不需要包或选项:

perl -e "map {$x += $_} <> and print $x" < infile.txt

你可以使用你喜欢的'expr'命令,你只需要先欺骗一下输入:

seq 10 | tr '[\n]' '+' | sed -e 's/+/ + /g' -e's/ + $/\n/' | xargs expr

流程如下:

"tr"将elon字符替换为+符号, Sed在“+”的两边加空格,然后从行中去掉最后的+ Xargs将管道输入插入到命令行,以便expr使用。


给红宝石爱好者

ruby -e "puts ARGF.map(&:to_i).inject(&:+)" numbers.txt

使用env变量tmp

tmp=awk -v tmp="$tmp" '{print $tmp" "$1}' <filename>|echo $tmp|sed "s/ /+/g"|bc

tmp=cat <filename>|awk -v tmp="$tmp" '{print $tmp" "$1}'|echo $tmp|sed "s/ /+/g"|bc

谢谢。


为了完整起见,这里还有一个R解

seq 1 10 | R -q -e "f <- file('stdin'); open(f); cat(sum(as.numeric(readLines(f))))"

不能避免提交这个,这是最通用的方法来解决这个问题,请查看:

jot 1000000 | sed '2,$s/$/+/;$s/$/p/' | dc

在这里可以找到,我是OP,答案来自观众:

最优雅的unix shell一行程序和任意精度的数字列表?

以下是它相对于awk、bc、perl、GNU的datamash及其朋友的特殊优势:

它使用任何Unix环境中常见的标准实用程序 它不依赖于缓冲,因此不会因为很长的输入而阻塞。 这意味着没有特定的精度限制-或整数大小的问题-你好AWK的朋友! 如果需要添加浮点数,则不需要不同的代码。 理论上它可以在最少的环境中不受阻碍地运行


我对现有的答案做了一个快速的基准测试

只使用标准工具(不好意思像lua或rocket), 都是真正的俏皮话, 能够添加大量的数字(1亿),和 速度很快(我忽略了那些超过一分钟的)。

我总是把数字从1亿加到1亿,这在我的机器上可以在一分钟内完成几个解决方案。

以下是调查结果:

Python

:; seq 100000000 | python -c 'import sys; print sum(map(int, sys.stdin))'
5000000050000000
# 30s
:; seq 100000000 | python -c 'import sys; print sum(int(s) for s in sys.stdin)'
5000000050000000
# 38s
:; seq 100000000 | python3 -c 'import sys; print(sum(int(s) for s in sys.stdin))'
5000000050000000
# 27s
:; seq 100000000 | python3 -c 'import sys; print(sum(map(int, sys.stdin)))'
5000000050000000
# 22s
:; seq 100000000 | pypy -c 'import sys; print(sum(map(int, sys.stdin)))'
5000000050000000
# 11s
:; seq 100000000 | pypy -c 'import sys; print(sum(int(s) for s in sys.stdin))'
5000000050000000
# 11s

Awk

:; seq 100000000 | awk '{s+=$1} END {print s}'
5000000050000000
# 22s

膏& Bc

我的机器内存不足了。它适用于一半大小的输入(5000万个数字):

:; seq 50000000 | paste -s -d+ - | bc
1250000025000000
# 17s
:; seq 50000001 100000000 | paste -s -d+ - | bc
3750000025000000
# 18s

所以我猜1亿个数字大约需要35秒。

Perl

:; seq 100000000 | perl -lne '$x += $_; END { print $x; }'
5000000050000000
# 15s
:; seq 100000000 | perl -e 'map {$x += $_} <> and print $x'
5000000050000000
# 48s

Ruby

:; seq 100000000 | ruby -e "puts ARGF.map(&:to_i).inject(&:+)"
5000000050000000
# 30s

C

为了比较起见,我编译了C版本并进行了测试,只是为了了解基于工具的解决方案有多慢。

#include <stdio.h>
int main(int argc, char** argv) {
    long sum = 0;
    long i = 0;
    while(scanf("%ld", &i) == 1) {
        sum = sum + i;
    }
    printf("%ld\n", sum);
    return 0;
}

 

:; seq 100000000 | ./a.out 
5000000050000000
# 8s

结论

C当然是用8秒最快的,但Pypy解决方案只增加了很少的开销,约为11秒的30%。但是,公平地说,Pypy并不是完全标准的。大多数人只安装了CPython,它非常慢(22秒),和流行的Awk解决方案一样快。

基于标准工具的最快解决方案是Perl(15秒)。


使用GNU数据集util:

seq 10 | datamash sum 1

输出:

55

如果输入的数据是不规则的,空格和制表符在奇怪的地方,这可能会混淆数据集,然后使用-W开关:

<commands...> | datamash -W sum 1

...或者使用tr清除空白:

<commands...> | tr -d '[[:blank:]]' | datamash sum 1

如果输入足够大,输出将采用科学计数法。

seq 100000000 | datamash sum 1

输出:

5.00000005e+15

要将其转换为十进制,使用——format选项:

seq 100000000 | datamash  --format '%.0f' sum 1

输出:

5000000050000000

好了,下面是如何在PowerShell (PowerShell核心,应该在Windows, Linux和Mac上工作)

Get-Content aaa.dat | Measure-Object -Sum

下面是一个漂亮而干净的Raku(以前称为Perl 6)一行程序:

say [+] slurp.lines

我们可以这样使用它:

% seq 10 | raku -e "say [+] slurp.lines"
55

它是这样工作的:

不带任何参数的Slurp默认从标准输入读取;它返回一个字符串。在字符串上调用lines方法将返回字符串的行列表。

+周围的括号将+转换为一个约简元操作符,将列表缩减为一个值:列表中值的和。Say然后用换行符将其打印到标准输出。

需要注意的一点是,我们从未显式地将行转换为数字——raku足够聪明,可以为我们做到这一点。然而,这意味着我们的代码在输入绝对不是数字时中断:

% echo "1\n2\nnot a number" | raku -e "say [+] slurp.lines"
Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏not a number' (indicated by ⏏)
  in block <unit> at -e line 1

更新的基准

所以我合成了随机分布的100mn个整数

之间的

0^0 - 1 

and

8^8 - 1

代码生成器

mawk2 '
BEGIN {
     __=_=((_+=_^=_<_)+(__=_*_*_))^(___=__)
     srand()
     ___^=___
     do  { 
           print int(rand()*___) 
  
     } while(--_)  }' | pvE9 > test_large_int_100mil_001.txt

     out9:  795MiB 0:00:11 [69.0MiB/s] [69.0MiB/s] [ <=> ]

  f='test_large_int_100mil_001.txt'
  wc5 < "${f}"

    rows = 100000000. | UTF8 chars = 833771780. | bytes = 833771780.

最后一位的奇/偶分布

Odd  49,992,332
Even 50,007,668

AWK -最快的,有很大的优势(可能C更快,我不知道)

in0:  795MiB 0:00:07 [ 103MiB/s] [ 103MiB/s] [============>] 100%            
( pvE 0.1 in0 < "${f}" | mawk2 '{ _+=$__ } END { print _ }'; )  

 7.64s user 0.35s system 103% cpu 7.727 total
     1  838885279378716

Perl -相当不错

 in0:  795MiB 0:00:10 [77.6MiB/s] [77.6MiB/s] [==============>] 100%            
( pvE 0.1 in0 < "${f}" | perl -lne '$x += $_; END { print $x; }'; )  
 
10.16s user 0.37s system 102% cpu 10.268 total

     1  838885279378716

Python3——稍微落后于Perl

 in0:  795MiB 0:00:11 [71.5MiB/s] [71.5MiB/s] [===========>] 100%            
( pvE 0.1 in0 < "${f}" | python3 -c ; )  

 11.00s user 0.43s system 102% cpu 11.140 total
     1  838885279378716

RUBY -不错

 in0:  795MiB 0:00:13 [61.0MiB/s] [61.0MiB/s] [===========>] 100%            
( pvE 0.1 in0 < "${f}" | ruby -e 'puts ARGF.map(&:to_i).inject(&:+)'; )  
15.30s user 0.70s system 101% cpu 15.757 total

     1  838885279378716

JQ -慢

 in0:  795MiB 0:00:25 [31.1MiB/s] [31.1MiB/s] [========>] 100%            
( pvE 0.1 in0 < "${f}" | jq -s 'add'; )  

 36.95s user 1.09s system 100% cpu 37.840 total

     1  838885279378716

DC

- ( had to kill it after no response in minutes)

awk的美妙之处在于,使用一个简单的整数流,它可以同时生成多个并发(可能是交叉交互的)序列,几乎不需要任何代码:

jot - -10 399 | 

mawk2 '__+=($++NF+=__+=-($++NF+=(--$!_)*9^9-1)+($!_^=2))' CONVFMT='%.20g'

121     4261625501                  -4261625380
100     12397455993                 -3874204891
81      28281696469                 -3486784402
64      59662756915                 -3099363913
49      122037457303                -2711943424
36      246399437577                -2324522935
25      494735977625                -1937102446
16      991021637223                -1549681957
9       1983205535923               -1162261468
4       3967185912829               -774840979
1       7934759246149               -387420490
0       15869518492299              -1
1       31738649564111              387420488
4       63476524287249              774840977
9       126951886313041             1162261466
16      253902222944143             1549681955
25      507802508785867             1937102444
36      1015602693048837            2324522933
49      2031202674154301            2711943422
64      4062402248944755            3099363911
81      8124801011105191            3486784400

这是一个不太为人所知的功能,但mawk-1可以直接生成格式化输出,而无需使用printf()或sprintf():

 jot - -11111111555359 900729999999999 49987777777556 | 
 
 mawk '$++NF=_+=$!__' CONVFMT='%+\047\043 30.f' OFS='\t' 

-11111111555359           -11,111,111,555,359.
38876666222197            +27,765,554,666,838.
88864443999753           +116,629,998,666,591.
138852221777309          +255,482,220,443,900.

188839999554865          +444,322,219,998,765.
238827777332421          +683,149,997,331,186.
288815555109977          +971,965,552,441,163.

338803332887533        +1,310,768,885,328,696.
388791110665089        +1,699,559,995,993,785.
438778888442645        +2,138,338,884,436,430.
488766666220201        +2,627,105,550,656,631.

538754443997757        +3,165,859,994,654,388.
588742221775313        +3,754,602,216,429,701.
638729999552869        +4,393,332,215,982,570.
688717777330425        +5,082,049,993,312,995.

738705555107981        +5,820,755,548,420,976.
788693332885537        +6,609,448,881,306,513.
838681110663093        +7,448,129,991,969,606.
888668888440649        +8,336,798,880,410,255.

使用nawk,一个更模糊的功能是能够打印出精确的IEEE 754双精度浮点十六进制:

 jot - .00001591111137777 \
       9007299999.1111111111 123.990333333328 | 

nawk '$++NF=_+=_+= cos(exp(log($!__)/1.1))' CONVFMT='[ %20.13p ]' OFS='\t' \_=1 

0.00001591111137777     [   0x400fffffffbf27f8 ]
123.99034924443937200   [   0x401f1a2498670bcc ]
247.98068257776736800   [   0x40313bd908775e35 ]
371.97101591109537821   [   0x4040516a505a57a3 ]
495.96134924442338843   [   0x4050b807540a1c3a ]

619.95168257775139864   [   0x4060f800d1abb906 ]
743.94201591107935201   [   0x407112ffc8adec4a ]
867.93234924440730538   [   0x40810bab4a485ad9 ]
991.92268257773525875   [   0x4091089e1149c279 ]

1115.91301591106321212  [   0x40a10ac8cfb09c62 ]
1239.90334924439116548  [   0x40b10a7bfa7fa42d ]
1363.89368257771911885  [   0x40c109c2d1b9947c ]
1487.88401591104707222  [   0x40d10a2644d5ab3b ]

gawk w/ GMP甚至更有趣-他们愿意为您提供逗号格式的十六进制,并在左侧空白区域添加奇怪的额外逗号

=

jot -  .000591111137777 90079.1111111111 123.990333333328 | 

gawk -v PREC=20000 -nMbe '
              $++NF  = _ +=(15^16 * log($!__)/log(sqrt(10)))' \
              CONVFMT='< 0x %\04724.12x >' OFS=' | '   \_=1 

# rows skipped in the middle for illustration clarity
 
4339.662257777619743 | < 0x    ,   ,4e6,007,2f4,08a,b93,8b3 >
4463.652591110947469 | < 0x    ,   ,50f,967,27f,e5a,963,518 >
4835.623591110930647 | < 0x    ,   ,58d,250,b65,a8d,45d,b79 >
7315.430257777485167 | < 0x    ,   ,8eb,b36,ee9,fe6,149,da5 >
11779.082257777283303 | < 0x    ,   ,f4b,c34,a75,82a,826,abb >

12151.053257777266481 | < 0x    ,   ,fd7,3c2,25e,1ab,a09,bbf >
16738.695591110394162 | < 0x    ,  1,6b0,f3b,350,ed3,eca,c58 >
17978.598924443671422 | < 0x    ,  1,894,2f2,aba,a30,f63,bae >
20458.405591110225942 | < 0x    ,  1,c64,a40,87e,e35,4d4,896 >
23434.173591110091365 | < 0x    ,  2,108,186,96e,0dc,2ef,d46 >

31741.525924443049007 | < 0x    ,  2,e45,bae,b73,24f,981,637 >
32857.438924442998541 | < 0x    ,  3,014,3a7,b9e,daf,18c,c3e >
33849.361591109620349 | < 0x    ,  3,1b0,9b7,5f1,536,49c,74e >
41536.762257775939361 | < 0x    ,  3,e51,7c1,9b2,e74,516,220 >
45876.423924442409771 | < 0x    ,  4,58c,52d,078,edb,db4,4ba >

53067.863257775417878 | < 0x    ,  5,1aa,cf3,eed,33c,638,456 >
59391.370257775131904 | < 0x    ,  5,c73,38a,54d,b41,98d,a02 >
61127.234924441720068 | < 0x    ,  5,f6d,ce2,c40,117,6d2,6e7 >
66830.790257774875499 | < 0x    ,  6,944,fe1,378,9ea,235,7b0 >
71170.451924441600568 | < 0x    ,  7,0ce,de6,797,df3,009,35d >

76254.055591108335648 | < 0x    ,  7,9b0,f6d,03d,878,edf,97d >
83073.523924441760755 | < 0x    ,  8,5b0,aa9,7f7,a31,89a,f2e >
86669.243591108475812 | < 0x    ,  8,c0d,678,fa3,3b1,aad,f26 >
89149.050257775175851 | < 0x    ,  9,074,278,19d,4c7,443,a00 >
89769.001924441850861 | < 0x    ,  9,18e,464,ff9,0eb,ee4,4e1 >

但是要对语法错误感到厌倦

这是打印到STDOUT的内容的选择, 所有256字节的选择都被打印出来,即使它是终端窗口

=

   jot 3000 | 
   gawk -Me ' _=$++NF=____+=$++NF=___-= $++NF=__+=$++NF=\
             _^= exp(cos($++NF=______+=($1) %10 + 1))'   \
                                  ____=-111111089 OFMT='%32c`' 


 char >>[  --[ U+ 2 | 2 (ASCII) freq >>[ 8 sumtotal >>[ 45151 
 char >>[  --[ U+ 4 | 4 (ASCII) freq >>[ 11 sumtotal >>[ 45166 
 char >>[  --[ U+ 14 | 20 (ASCII) freq >>[ 9 sumtotal >>[ 45301 
 char >>[ + --[ U+ 2B | 43 (ASCII) freq >>[ 9 sumtotal >>[ 60645 
 char >>[ --[ U+ 9 | 9 (ASCII) freq >>[ 12 sumtotal >>[ 45216 
 char >>[ 8 --[ U+ 38 | 56 (ASCII) freq >>[ 1682 sumtotal >>[ 82522 
 char >>[ Q --[ U+ 51 | 81 (ASCII) freq >>[ 6 sumtotal >>[ 85040 
 char >>[ Y --[ U+ 59 | 89 (ASCII) freq >>[ 8 sumtotal >>[ 85105 
 char >>[ g --[ U+ 67 | 103 (ASCII) freq >>[ 10 sumtotal >>[ 85212 
 char >>[ p --[ U+ 70 | 112 (ASCII) freq >>[ 7 sumtotal >>[ 85411 
 char >>[ v --[ U+ 76 | 118 (ASCII) freq >>[ 7 sumtotal >>[ 85462 
 char >>[ ? --[ \216 \x8E | 142 (8-bit byte) freq >>[ 15 sumtotal >>[ 85653 
 char >>[ ? --[ \222 \x92 | 146 (8-bit byte) freq >>[ 13 sumtotal >>[ 85698 
 char >>[ ? --[ \250 \xA8 | 168 (8-bit byte) freq >>[ 9 sumtotal >>[ 85967 
 char >>[ ? --[ \307 \xC7 | 199 (8-bit byte) freq >>[ 7 sumtotal >>[ 86345 
 char >>[ ? --[ \332 \xDA | 218 (8-bit byte) freq >>[ 69 sumtotal >>[ 86576 
 char >>[ ? --[ \352 \xEA | 234 (8-bit byte) freq >>[ 6 sumtotal >>[ 86702 
 char >>[ ? --[ \354 \xEC | 236 (8-bit byte) freq >>[ 5 sumtotal >>[ 86713 
 char >>[ ? --[ \372 \xFA | 250 (8-bit byte) freq >>[ 11 sumtotal >>[ 86823 
 char >>[ ? --[ \376 \xFE | 254 (8-bit byte) freq >>[ 9 sumtotal >>[ 86859