Visit The New, Modern Unix Linux Community

Top Forums Shell Programming and Scripting Merging Lines based on criteria Post 302615123 by losttouch on Thursday 29th of March 2012 07:33:22 AM
Merging Lines based on criteria


Need help with following scenario.

A file contains following text:

{beginning of file}
New: This is a new record and it is not
on same line. Since I have lost touch with script
take this challenge and bring all this in one line.
New: Hello losttouch. You seem to be struggling with 
this really simple challenge.
New: It is better that I ask some expert on
They will show you this is simple enough.
{end of file}

What I am trying to accomplish is to get all the lines starting from "New:" until next "New:" is read; on to one line. Resultant lines should be like:

New: This is a new record and it is not on same line. Since I have lost touch with script take this challenge and bring all this in one line.
New: Hello losttouch. You seem to be struggling with this really simple challenge.
New: It is better that I ask some expert on will show you this is simple enough.

As I mentioned in the above statements, I have lost touch with this, I am really struggling to accomplish this task. Any help is greatly appreciated.

Thanks so much.

EDIT: Needless to say that if I read next "New:" (lets say in any variable) it implies, my previous record is complete and should be displayed or appended to a file.

Last edited by Scrutinizer; 03-29-2012 at 09:23 AM.. Reason: Please Use [code] tags [/code], thank you..
Test Your Knowledge in Computers #65
Difficulty: Easy
In the TCP/IP model, end-to-end connectivity is provided from host-to-host in the transport layer.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging lines based on occurances of a particular character in a file

Hi, Is there any way to merge two lines based on specific occurance of a character in a file. I am having a flat file which contains multiple records. Each row in the file should contain specified number of delimiter. For a particular row , if the delimiter count is not matched with... (2 Replies)
Discussion started by: mohan_tuty
2 Replies

2. Shell Programming and Scripting

remove lines based on score criteria

Hi guys, Please guide for Solution. PART-I INPUT FILE (has 2 columns ID and score) TC5584_1 93.9 DV161411_2 79.5 BP132435_5 46.8 EB682112_1 34.7 BP132435_4 29.5 TC13860_2 10.1 OUTPUT FILE (It shudn't contain the line ' BP132435_4 29.5 ' as BP132435 is repeated... (2 Replies)
Discussion started by: smriti_shridhar
2 Replies

3. Shell Programming and Scripting

Append specific lines to a previous line based on sequential search criteria

I'll try explain this as best I can. Let me know if it is not clear. I have large text files that contain data as such: 143593502 09-08-20 09:02:13 xxxxxxxxxxx xxxxxxxxxxx 09-08-20 09:02:11 N line 1 test line 2 test line 3 test 143593503 09-08-20 09:02:13... (3 Replies)
Discussion started by: jesse
3 Replies

4. Shell Programming and Scripting

Delete new lines based on search criteria

Hi all! A bit of background: I am trying to create a script that formats SQL statements. I have gotten so far as to add new lines based on certain match criteria like commas, keywords etc. In the process, I end up adding newlines where I don't want. For example: substr(colName, 1, 10)... (3 Replies)
Discussion started by: jayarkay
3 Replies

5. Shell Programming and Scripting

Select lines from a file based on a criteria

Hi I need to select lines from a txt file, I have got a line starting with ZMIO:MSISDN= and after a few line I have another line starting with 'MOBILE STATION ISDN NUMBER' and another one starting with 'VLR-ADDRESS' I need to copy these three lines as three different columns in a separate... (3 Replies)
Discussion started by: Tlcm sam
3 Replies

6. Shell Programming and Scripting

Need To Delete Lines Based On Search Criteria

Hi All, I have following input file. I wish to retain those lines which match multiple search criteria. The search criteria is stored in a variable seperated from each other by comma(,). SEARCH_CRITERIA = "REJECT, DUPLICATE" Input File: ERROR,MYFILE_20130214_11387,9,37.75... (3 Replies)
Discussion started by: angshuman
3 Replies

7. UNIX for Dummies Questions & Answers

Merging lines based on one column

Hi, I have a file which I'd like to merge lines based on duplicates in one column while keeping the info for other columns. Let me simplify it by an example: File ESR1 ANASTROZOLE NA FDA_approved ESR1 CISPLATIN NA FDA_approved ESR1 DANAZOL agonist NA ESR1 EXEMESTANE NA FDA_approved... (3 Replies)
Discussion started by: JJ001
3 Replies

8. Shell Programming and Scripting

Merging 2 lines based on a string

Dear Unix gurus I need help with a command or script to merge 2 lines where ever we find the string. I have attached scanned document. First line has string value: VSIN, immediate line has value: SETTLEMENT Where it finds the 2 string values in the whole file, one below the other,... (8 Replies)
Discussion started by: Karunyam
8 Replies

9. UNIX for Beginners Questions & Answers

Merging multiple lines into single line based on one column

I Want to merge multiple lines based on the 1st field and keep into single record. SRC File: AAA_POC_DB.TAB1 AAA_POC_DB.TAB2 AAA_POC_DB.TAB3 AAA_POC_DB.TAB4 BBB_POC_DB.TAB1 BBB_POC_DB.TAB2 CCC_POC_DB.TAB6 OUTPUT ----------------- 'AAA_POC_DB','TAB1','TAB2','TAB3','TAB4'... (10 Replies)
Discussion started by: raju2016
10 Replies

10. UNIX for Beginners Questions & Answers

Remove lines from File.A based on criteria in File.B

Hello, I have two files of the following form. I would like to remove from File.A where the first three colum matches values in File.B to give the output in File.C File.A 121 54321 PQR CAT 122 765431 ABC DOG 124 98765 ZXY TIGER 125 86432 GEF LION File.B 122 765431 ABC 125 86432 GEF... (4 Replies)
Discussion started by: Gussifinknottle
4 Replies
sasl_checkapop(3SASL)			      Simple Authentication Security Layer Library Functions			     sasl_checkapop(3SASL)

sasl_checkapop - check an APOP challenge or response SYNOPSIS
cc [ flag ... ] file ... -lsasl [ library ... ] #include <sasl/sasl.h> int sasl_checkapop(sasl_conn_t *conn, const char *challenge, unsigned challen, const char *response, unsigned resplen); DESCRIPTION
The sasl_checkapop() interface checks an APOP challenge or response. APOP is an option POP3 authentication command that uses a shared secret password. See RFC 1939. If sasl_checkapop() is called with a NULL challenge, sasl_checkapop() will check to see if the APOP mechanism is enabled. PARAMETERS
conn The sasl_conn_t for which the request is being made challenge The challenge sent to the client challen The length of challenge response The client response resplens The length of response RETURN VALUES
sasl_checkapop() returns an integer that corresponds to a SASL error code. ERRORS
SASL_OK Indicates that the authentication is complete All other error codes indicate an error situation that must be handled, or the authentication session should be quit. See sasl_errors(3SASL) for information on SASL error codes. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |SUNWlibsasl | +-----------------------------+-----------------------------+ |Interface Stability |Obsolete | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
sasl_errors(3SASL), attributes(5) Meyers, J. and Rose, M. RFC 1939, Post Office Protocol - Version 3. Network Working Group. May 1996. SunOS 5.10 14 Oct 2003 sasl_checkapop(3SASL)

Featured Tech Videos

All times are GMT -4. The time now is 09:36 PM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy