将持续数量插入多个文件-Linux控制台
我有一个更大的文件(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 of00h 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
substring
-ing位至500个相对小。这是一个代码段,在Integer
$ 1
以1
开始,然后返回2-LETTER
序列akin Akin如何将其命名命名为依次。26
和97(ASCII#4“ A”)
。在
ascii
中,将其字母范围扩展到所有[:]
,而不是仅仅是小写字母,不应该太难将其字母范围扩展到所有[:]
the
substring
-ing bits to 500 apiece should be relatively trivial. Here's a code snippet that takesinteger
inputs at$1
starting with1
, and returns a2-letter
sequence akin to how split name their files sequentially.26
and97 ( ascii # 4 "a" )
.It shouldn't be too hard to expand its alphabet range to all
[:alpha:]
withinASCII
instead of just lowercase