tr ' -' ' _' < file1 | # dashes -> underscores per dc requirements
dc -e "
[q]sq # macro for quitting
[z :x z0<a]sa # macro for main stack -> array x[]
[z ;x -SM z0<b]sb # macro for doing: stack M = stack[i]-x[i]
[LMdn32an zlk>c]sc # macro for printing stack M elements
[?z0=q lbx lcx 10Pc z0=?]s? # do-while loop to read in file1 per line and run the macros "b" then "c"
$(< file2 tr ' -' ' _') # load up the main stack with file2
zsk lax l?x # store cols in reg. k, call macro "a" and
" > file3
Результаты
0 0 0 0
2 0 4 0
0 4 7 1
Предположения
- GNU dc
- Столько же столбцов в файле1 и файле2, но они должны быть одинаковыми.
KKD
06.02.2016, 11:25
Ссылка