使用sed的使用SED无法找到这种情况下,任何解决方案:合并入行没有“空间”巨大的单行中的.txt文件
我有包含平均超过30〜行.txt文件。 我需要将所有行合并到一个没有任何“空格”的每个文件(N个文件但少于1000个)的单个巨大行中,并将此行粘贴到一个新行(每个txt文件数据为1行)。需要这种格式来解析.csv表。
实施例:
文件1:
This file
Contains text
to merge into
a single line without any
space between characters
文件2:
This file
Contains almost the same text
to merge into
a single line without any
space or blanks between characters after the merge
文件N:
This file
Contains equal text
to merge into
a single line without any
space between characters
输出:
This FileContains Textto Merge intoa single line without anyspace between characters
This fileContains almost the same texto merge intoa single line without anyspace or blanks between characters after the merge
This fileContains equal textto merge intoa single line without anyspace between characters
试图用:
sed -e :a -e '/$/N; s/\n//; ta' test.txt
没有工作。文本保持不变
样本数据:
6150217008*AA*31/1*1
0*4611*1
349*9171*349*9171*0*0
403*9481*403*9481*0*0
C3*25*
718*17399*718*17399*0*0
C4*25*
794*19293*794*19293*0*0
C5*25*
731*17594*731*17594*0*0
C6*25*
需要得到: 6150217008 * AA *1分之31* 10 * 4611 * 1349 * 9171 * 349 * 9171 * 0 * 0403 * 9481 * 403 * 9481 * 0 * 0C3 * 2 ....等
巨大的单一原始行文本没有任何空格。
我该如何做到这一点?谢谢!
'sed':1; s/^ [] * //; s/[] * $ //; $!{N; s/\ n //; B1}'' – 123
6150217008 * VA * V1/1 * 1 DIX * DN 5800-4 * 7008 ** * EVS3.1 0 * 4611 * 1 865616 * 37165 * 865616 * 37165 * 0 * 0 等.. 几乎删除所有行,但不是全部 –
也许你应该编辑你的Sample Data,因为它没有显示任何空格,我想它应该包含一些。 – vdavid