将持续数量插入多个文件-Linux控制台

发布于 2025-02-08 18:32:36 字数 1231 浏览 3 评论 0原文

我有一个更大的文件(16192次0),需要将其分成500个字符段。

我这样做:

split 1.txt -b500 1_split.txt

这为我提供了33个文件,带有1_split.txtaa到1_split.txtbg,

我需要现在每个文件中都有一个持续数字的文本 - 就像

parts:
1=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

在1_split.txtaa中直到第33部分in 1_split.txtbf,

它甚至可以用

parts:
1=000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h

它以一种奇怪的格式来使用它的frade 2和taff thaled h,thee thee theces and the the thee the the the the Spaces :(

即使我需要的那样, 它给了我一个奇怪的输出

cat 1_split.txt* | fold -w2 | paste -sd 'h'

使用折叠,但不幸的是,不幸的是, 00H 00H

我也不知道如何将更改保存到刚刚打开的文件中。 fold -w0不起作用,所以我不知道添加领先0是否好。

是否宁愿有人对Echo,printf,awk或sed做什么? :(

善意的问候和感谢!

乔纳斯

I'm having a bigger file (16192 times 0) that I need to split up into 500 character segments.

I do it like that:

split 1.txt -b500 1_split.txt

This gives me 33 files with 1_split.txtaa to 1_split.txtbg

I need to have a text with ongoing number in each file now -
like

parts:
1=0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

in 1_split.txtaa till part 33 in 1_split.txtbf

It would be farorable to have it even like that

parts:
1=000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h 000h

As I need it in a strange formatting with leading 2 and trailing h for every byte - seperated with spaces :(

For this I played around with fold but unfortunately it gives me a strange output by doing

cat 1_split.txt* | fold -w2 | paste -sd 'h'

Unfortunately it gives me 00h 0h0 already at the beginning instead of
00h 00h

Nor do I know how to save the changes to the just opened file yet. Also fold -w0 doesn't work so I don't know if its good to add the leading 0.

Is it something somebody would rather do with echo, printf, awk or sed? :(

Kind regards and thanks in advance!

Jonas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月流歌 2025-02-15 18:32:36

substring -ing位至500个相对小。这是一个代码段,在Integer $ 11开始,然后返回2-LETTER序列akin Akin如何将其命名命名为依次。

  • 内部使用的2个常数为2697(ASCII#4“ A”)

ascii中,将其字母范围扩展到所有[:],而不是仅仅是小写字母,不应该太难将其字母范围扩展到所有[:]

{m,g}awk 'BEGIN { __ = (_+=_+=_^=_<_)^--_-_+_*_*++_+\
                      !(___ = -(_-++_*++_)) + !(_^=!_)

} $++NF = sprintf("%c%c", int((____=-_+$_)/___)+__, ____%___+__) '



 1 aa   58 cf   115 ek  172 gp  229 iu  286 kz  343 ne  400 pj  457 ro  514 tt  571 vy  628 yd
 5 ae   62 cj   119 eo  176 gt  233 iy  290 ld  347 ni  404 pn  461 rs  518 tx  575 wc  632 yh
 9 ai   66 cn   123 es  180 gx  237 jc  294 lh  351 nm  408 pr  465 rw  522 ub  579 wg  636 yl
 13 am  70 cr   127 ew  184 hb  241 jg  298 ll  355 nq  412 pv  469 sa  526 uf  583 wk  640 yp
 
 17 aq  74 cv   131 fa  188 hf  245 jk  302 lp  359 nu  416 pz  473 se  530 uj  587 wo  644 yt
 21 au  78 cz   135 fe  192 hj  249 jo  306 lt  363 ny  420 qd  477 si  534 un  591 ws  648 yx
 25 ay  82 dd   139 fi  196 hn  253 js  310 lx  367 oc  424 qh  481 sm  538 ur  595 ww  652 zb
 29 bc  86 dh   143 fm  200 hr  257 jw  314 mb  371 og  428 ql  485 sq  542 uv  599 xa  656 zf
 
 33 bg  90 dl   147 fq  204 hv  261 ka  318 mf  375 ok  432 qp  489 su  546 uz  603 xe  660 zj
 37 bk  94 dp   151 fu  208 hz  265 ke  322 mj  379 oo  436 qt  493 sy  550 vd  607 xi  664 zn
 41 bo  98 dt   155 fy  212 id  269 ki  326 mn  383 os  440 qx  497 tc  554 vh  611 xm  668 zr
 45 bs  102 dx  159 gc  216 ih  273 km  330 mr  387 ow  444 rb  501 tg  558 vl  615 xq  672 zv
 
 49 bw  106 eb  163 gg  220 il  277 kq  334 mv  391 pa  448 rf  505 tk  562 vp  619 xu  676 zz
 53 ca  110 ef  167 gk  224 ip  281 ku  338 mz  395 pe  452 rj  509 to  566 vt  623 xy
 57 ce  114 ej  171 go  228 it  285 ky  342 nd  399 pi  456 rn  513 ts  570 vx  627 yc

the substring-ing bits to 500 apiece should be relatively trivial. Here's a code snippet that takes integer inputs at $1 starting with 1, and returns a 2-letter sequence akin to how split name their files sequentially.

  • The 2 constants used inside are 26 and 97 ( ascii # 4 "a" ).

It shouldn't be too hard to expand its alphabet range to all [:alpha:] within ASCII instead of just lowercase

{m,g}awk 'BEGIN { __ = (_+=_+=_^=_<_)^--_-_+_*_*++_+\
                      !(___ = -(_-++_*++_)) + !(_^=!_)

} $++NF = sprintf("%c%c", int((____=-_+$_)/___)+__, ____%___+__) '



 1 aa   58 cf   115 ek  172 gp  229 iu  286 kz  343 ne  400 pj  457 ro  514 tt  571 vy  628 yd
 5 ae   62 cj   119 eo  176 gt  233 iy  290 ld  347 ni  404 pn  461 rs  518 tx  575 wc  632 yh
 9 ai   66 cn   123 es  180 gx  237 jc  294 lh  351 nm  408 pr  465 rw  522 ub  579 wg  636 yl
 13 am  70 cr   127 ew  184 hb  241 jg  298 ll  355 nq  412 pv  469 sa  526 uf  583 wk  640 yp
 
 17 aq  74 cv   131 fa  188 hf  245 jk  302 lp  359 nu  416 pz  473 se  530 uj  587 wo  644 yt
 21 au  78 cz   135 fe  192 hj  249 jo  306 lt  363 ny  420 qd  477 si  534 un  591 ws  648 yx
 25 ay  82 dd   139 fi  196 hn  253 js  310 lx  367 oc  424 qh  481 sm  538 ur  595 ww  652 zb
 29 bc  86 dh   143 fm  200 hr  257 jw  314 mb  371 og  428 ql  485 sq  542 uv  599 xa  656 zf
 
 33 bg  90 dl   147 fq  204 hv  261 ka  318 mf  375 ok  432 qp  489 su  546 uz  603 xe  660 zj
 37 bk  94 dp   151 fu  208 hz  265 ke  322 mj  379 oo  436 qt  493 sy  550 vd  607 xi  664 zn
 41 bo  98 dt   155 fy  212 id  269 ki  326 mn  383 os  440 qx  497 tc  554 vh  611 xm  668 zr
 45 bs  102 dx  159 gc  216 ih  273 km  330 mr  387 ow  444 rb  501 tg  558 vl  615 xq  672 zv
 
 49 bw  106 eb  163 gg  220 il  277 kq  334 mv  391 pa  448 rf  505 tk  562 vp  619 xu  676 zz
 53 ca  110 ef  167 gk  224 ip  281 ku  338 mz  395 pe  452 rj  509 to  566 vt  623 xy
 57 ce  114 ej  171 go  228 it  285 ky  342 nd  399 pi  456 rn  513 ts  570 vx  627 yc
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文