Sponsored Content
Full Discussion: Combining lines in one line
Top Forums UNIX for Beginners Questions & Answers Combining lines in one line Post 303015390 by scriptor on Wednesday 4th of April 2018 04:05:33 AM
Old 04-04-2018
Combining lines in one line

Hi
below is the input file snippet.
here i want that all the line which is coming after 1 shoud be in one line.
so for exanple if after 1 there is two lines which is starting with 2 should be combine in one line.
input file content
Code:
1,8091012,BATCH_1430903_01,21,T,2,808738,,,,21121:87:01,
2,A,79020:04:25,IC,,
2,D,89014:03:40,u,7239021674,
1,5390021,BATCH_1330903_02,21,T,2,306738,,,,21121:15:01,
2,A,6190:05:09,IC,,
1,9650123,BATCH_1110903_02,21,T,3,904428,,,,21121:34:11,
2,A,9270:00:22,IC,,
1,9992013,BATCH_1000903_06,21,T,7,50128,,,,21121:99:15,
2,A,7790:05:24,IC,,

Required O/P
Code:
1,8091012,BATCH_1430903_01,21,T,2,808731,,,,21121:87:01,|2,A,79020:04:25,IC,,|2,D,89014:03:40,u,7239021674,
1,5390021,BATCH_1330903_02,21,T,2,306730,,,,21121:15:01,|2,A,6190:05:09,IC,,
1,9650123,BATCH_1110903_02,21,T,3,904429,,,,21121:34:11,|2,A,9270:00:22,IC,,
1,9992013,BATCH_1000903_06,21,T,7,501283,,,,21121:99:15,|2,A,7790:05:24,IC,,


Last edited by joeyg; 04-05-2018 at 09:06 AM.. Reason: fixed title
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need help appending lines/combining lines within a file...

Is there a way to combine two lines onto a single line...append the following line onto the previous line? I have the following file that contains some blank lines and some lines I would like to append to the previous line... current file: checking dsk c19t2d6 checking dsk c19t2d7 ... (2 Replies)
Discussion started by: mr_manny
2 Replies

2. Shell Programming and Scripting

Combining lines between two specific lines

Hi, I have a requirement like following: I have input file like: Question: 1 ----Multiple choice--- What is your favourite colour? Options: a) red b) blue c) none of these Question: 2 ---Multiple choice----- In which month did you join your first job? Options: a) Jan b) Feb c)... (11 Replies)
Discussion started by: ppatra
11 Replies

3. Shell Programming and Scripting

Combining 2 lines in a file into 1 line

Hi all, I have a file with lot of lines with repeating pattern. ( TABLE_NAME line followed by Total line). I would like combine these two lines into one line seperated by cama and create a new file. Is there a simple way to do this. Current Format ( just a sample 4 lines ) TABLE_NAME:... (10 Replies)
Discussion started by: MKNENI
10 Replies

4. Programming

PERL:Combining multiple lines to single line

Hi All I need a small help for the below format in making a small script in Perl or Shell. I have a file in which a single line entries are broken into three line entries. Eg: I have a pen and notebook. All i want is to capture in a single line in a separate file. eg: I have a pen and... (4 Replies)
Discussion started by: Kalaiela
4 Replies

5. Shell Programming and Scripting

Reading two lines in a while loop and combining the lines

Dear all, I have a file like this: imput scaffold_0 1 scaffold_0 10000 scaffold_0 20000 scaffold_0 25000 scaffold_1 1 scaffold_1 10000 scaffold_1 20000 scaffold_1 23283 and I want the output like this: scaffold_0 1 scaffold_0 10000 scaffold_0 10000 scaffold_0 20000... (6 Replies)
Discussion started by: valente
6 Replies

6. Shell Programming and Scripting

Combining lines in to one line

Hi Friends, I have a file1.txt 1001 jkilo yrhfm 200056 jhdf rjhwjkrh 3+u8jk5h3 uru ehjk 1002 jkfhk hfjkd 2748395 fdjksfh hefjkh 3hdfk ejkh kjhjke In the above if you see the firt charcter of each line mentioned in red has a pattern . I need to create another file where , the... (6 Replies)
Discussion started by: i150371485
6 Replies

7. Shell Programming and Scripting

Combining multiple block of lines in one comma separated line

Hi Everyone, On my Linux box I have a text file having block of few lines and this block lines separated by one blank line. I would like to format and print these lines in such a way that this entire block of lines will come as single comma separated line & again next block of lines in next... (7 Replies)
Discussion started by: gr8_usk
7 Replies

8. Shell Programming and Scripting

Combining two lines into one, UNIX

Hi All, I have a file which has the following sample lines -- <Member name="Canada" Currency="CAD" -- <Member name="UK" Currency="GBP" -- <Member name="Switzerland" Currency="CHF" -- <Member name="Germany" Currency="EUR" -- (11 Replies)
Discussion started by: dev.devil.1983
11 Replies

9. Shell Programming and Scripting

Combining lines into a single line

i have a file (where the column values are separated by ' and the text can be enclosed in ~) which contains data in form of 4461,2,~Basic: 2 Years/Unlimited Miles Drivetrain: Gas Engine 2 Years/Unlimited Miles Duramax Engine 3 Years/Unlimited... (2 Replies)
Discussion started by: rahulchandak
2 Replies

10. Shell Programming and Scripting

Log4j combining lines to single line

Hi, Our log4j file contents look like this: 2018-11-20T00:06:58,888 INFO ql.Driver: Executing command(queryId=hive_20181120000656_49af4ad0-1d37-4312-872c-a247ed80c181): CREATE TABLE RESULTS.E7014485_ALL_HMS_CAP1 AS SELECT name,dept from employee Where employee='Jeff'... (4 Replies)
Discussion started by: wahi80
4 Replies
recordio(1)                                                   General Commands Manual                                                  recordio(1)

NAME
recordio - record the input and output of a program SYNTAX
recordio program [ arg ... ] DESCRIPTION
recordio runs program with the given arguments. It prints lines to stderr showing the input and output of program. At the beginning of each line on stderr, recordio inserts the program process ID, along with < for input or > for output. At the end of each line it inserts a space, a plus sign, or [EOF]; a space indicates that there was a newline in the input or output, and [EOF] indicates the end of input or output. recordio prints every packet of input and output immediately. It does not attempt to combine packets into coherent stderr lines. For example, recordio sh -c 'cat /dev/fd/8 2>&1' > /dev/null could produce 5135 > cat: /dev/fd/8: Bad file descriptor 5135 > [EOF] or 5135 > cat: + 5135 > /dev/fd/8+ 5135 > : + 5135 > Bad file descriptor 5135 > [EOF] recordio uses several lines for long packets to guarantee that each line is printed atomically to stderr. recordio runs as a child of program. It exits when it sees the end of program's output. SEE ALSO
tcpserver(1) recordio(1)
All times are GMT -4. The time now is 05:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy