使用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