Need help in concat of two lines in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in concat of two lines in a file
# 1  
Old 08-25-2010
Need help in concat of two lines in a file

Hi ,

Need help in concating two lines based on certain character, for example my file has the messages :

Code:
:57A:qweqweww
:58A:qeqewqeqe
-}$
{1:fffff2232323}{2:123123dasds}{4:
:20:121323232323232
:21:sdsadasdasddadad

if the line ends with "-}$" or if a line starts with "{1:" then it should append the next line or to the previous line , like below

Code:
:57A:qweqweww
:58A:qeqewqeqe
-}${1:fffff2232323}{2:123123dasds}{4:
:20:121323232323232
:21:sdsadasdasddadad


Last edited by Scott; 08-25-2010 at 03:02 PM.. Reason: Please use code tags
# 2  
Old 08-25-2010
Code:
perl -pe 's/(?<=-}\$)\n//' file

# 3  
Old 08-25-2010
Thanks for your post, can you please provide me a command in shell script please..
# 4  
Old 08-25-2010
This command can be used in shell script.
This User Gave Thanks to bartus11 For This Post:
# 5  
Old 08-25-2010
Code:
sed '/-\}\$$/N;s/\n//' infile
:57A:qweqweww
:58A:qeqewqeqe
-}${1:fffff2232323}{2:123123dasds}{4:
:20:121323232323232
:21:sdsadasdasddadad

# 6  
Old 08-25-2010
Thanks both..it worked !!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concat name

Hi, I need help to combine the first 7 character of firstname if it is longer than 7and combine with the first character of lastname. ex: username lastname => usernaml user lastname => userl Thanks in advance. (10 Replies)
Discussion started by: xitrum
10 Replies

2. UNIX for Dummies Questions & Answers

concat any two lines in a file

I have a file with line 4 : F SITE SPA_M2 SPA_M3 SPA_M4 and a line 237 with: BV_N4 VbdGO_PW Rs_NW_STI Rc_N+OD need a awk liner to concat the two lines so that line 2 sits next to line1 and looks like: F SITE SPA_M2 SPA_M3 SPA_M4 BV_N4 VbdGO_PW ... (8 Replies)
Discussion started by: awkaddict
8 Replies

3. Shell Programming and Scripting

awk concat lines between 2 sequent digits

I would like to print string between two sequent digits and concatenate it into one single line. input.txt 99 cord, rope, strand, twine, twist, 100 strand, twine, twist, cord, rope 101 strand, twine, twist, twine, twist, cord, rope 105 cord, rope ,twi ... (8 Replies)
Discussion started by: sdf
8 Replies

4. Shell Programming and Scripting

Concat

Hi All, My Input file contains: Input.txt Name|Marks ABC|10 GHI|10 JKL|20 MNO|20 PQR|30 Output.txt MARKS|NAME 10|ABC,GHI 20|JKL,MNO 30|PQR Thanks in advance (4 Replies)
Discussion started by: kmsekhar
4 Replies

5. Shell Programming and Scripting

How to concat lines that have the same key field

Hi, I have file like this - ABC 123 ABC 456 ABC 321 CDE 789 CDE 345 FGH 111 FGH 222 FGH 333 XYZ 678 I need the output like this: ABC 123,456 CDE 789,345 FGH 111, 222 XYZ 678 Meaning I want to concat the lines that have the same first column, but I only need the first two... (10 Replies)
Discussion started by: redwing
10 Replies

6. Programming

Concat of two html file

By launching two SQL scripts I get two html files report_1.html and report_2.html with different background and text colors (white/blue for the former and silver/black for the latter) but if I try to concat the two html by using the CAT function on UNIX Server where Oracle is installed (cat... (1 Reply)
Discussion started by: Mark1970
1 Replies

7. Shell Programming and Scripting

Conditional concat lines awk

Hello, I have a text file like this: NONE FILE_Rename frompath: /log_audit/AIX/log/current/AIXAFTPP.log NONE FILE_Unlink filename /audit/tempfile.14041142 NONE FILE_Rename ... (8 Replies)
Discussion started by: carloskl
8 Replies

8. Shell Programming and Scripting

concat 6 files in 1 file ( maybe use AWK?)

hi, I have the following problem: - 6 different files that have one key in common. - this six files must be aggregated in one output file sorted by the key. - the main file has to be writen twice, one in the beggining of the new output file and another in the end, for each key. - add one... (3 Replies)
Discussion started by: naoseionome
3 Replies

9. UNIX for Dummies Questions & Answers

Search and then concat 4m other file (comma seperated)

My query is now a bit simplified. file1.txt names; ID; value1 ; values N; ABC; 1 ; a18 ; ... CDF; 2 ; b16 ; .. ABC; 1 ; c13 ; ...... EFG; 3 ;d12 ; ... file2.txt ID(Unique);smVals; smVal1; smVal N; 1; ...; ...; ...; 2; ..; ..; ..; 3; ..; ..; ..; ... (1 Reply)
Discussion started by: szchmaltz
1 Replies

10. Shell Programming and Scripting

Concat

HI all, How to concat two strings in Shell scrpits suppose x=a y=b i want to display it as ab How to do it ? Thanks.. (1 Reply)
Discussion started by: dhananjaysk
1 Replies
Login or Register to Ask a Question