Sponsored Content
Top Forums UNIX for Advanced & Expert Users Replace \n char true line Separator Post 303026229 by rajeshkumare on Thursday 22nd of November 2018 04:49:44 AM
Old 11-22-2018
Replace \n char true line Separator

Unix File is pipe delimited with 17 fields. We may get extra pipes in data also.
We may get \n char (1 or more \n in one field or multi fileds) in data in any field.
Need to replace \n true ( line separator) with 'space and bell char space' chars (' \a ') Not data \n.

Input:
455000|TTTT|97233|UUUUUU REP||Juli||EEEE||P.O. Box | 550 MMMMMMMMMM JJ 55555|||||||
333333|DDD|97233|UUUUUU REP||AMAR||AJAY||P.O. Box 69 MMMMMMMMMM | JJ 6666
JJJ BBBB P.O. Box 4 MMMMMMMMMM JJ 44444
delmer Speidel P.O. Box 242 MMMMMMMMMM JJ 99456, See File For More.....|||||||
888888|Director|97382|UUUUUU REP||ANTHONY|K|JOSHI||1144 JNM ROAD LLLLLLLLLLLLL | JJ 82513, Laurie Ideker, Leon Sanderson
coralie Emmons P.O. Box 34 LLLLLLLLLLLLL JJ 82513
wanda Knowles P.O. Box 958 LLLLLLLLLLLLL JJ 82513, See File For More...|||||||
999999|President|97692|UUUUUU REP||See||File|||||||||

Expected Output:
455000|TTTT|97233|UUUUUU REP||Juli||EEEE||P.O. Box | 550 MMMMMMMMMM JJ 55555||||||| \a 333333|DDD|97233|UUUUUU REP||AMAR||AJAY||P.O. Box 69 MMMMMMMMMM | JJ 6666
JJJ BBBB P.O. Box 4 MMMMMMMMMM JJ 44444
delmer Speidel P.O. Box 242 MMMMMMMMMM JJ 99456, See File For More.....||||||| \a 888888|Director|97382|UUUUUU REP||ANTHONY|K|JOSHI||1144 JNM ROAD LLLLLLLLLLLLL | JJ 82513, Laurie Ideker, Leon Sanderson
coralie Emmons P.O. Box 34 LLLLLLLLLLLLL JJ 82513
wanda Knowles P.O. Box 958 LLLLLLLLLLLLL JJ 82513, See File For More...||||||| \a 999999|President|97692|UUUUUU REP||See||File|||||||||
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace any char with newline char.

Hi, How to replace any character in a file with a newline character using sed .. Ex: To replace ',' with newline Input: abcd,efgh,ijkl,mnop Output: abcd efgh ijkl mnop Thnx in advance. Regards, Sasidhar (5 Replies)
Discussion started by: mightysam
5 Replies

2. Shell Programming and Scripting

SED: Place char at starting and replace selected line

Hello Experts, I am working on a small file editing script. Since all experts here are very generous to give me the complete code, I would take up the problem in steps so that I ensure my opportunity to learn. AIM: The script has some commented and some uncommented lines. I need to : ... (2 Replies)
Discussion started by: hkansal
2 Replies

3. Shell Programming and Scripting

how first char in odd line and second char in even line

Hi I m having ifconfig -a o/p like sbanlab1:ksh# ifconfig -a | egrep "flags|inet" | awk -F' ' '{print $1,$2}' lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> inet 127.0.0.1 lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> inet 127.0.0.1 bge0:... (1 Reply)
Discussion started by: tarunn.dubeyy
1 Replies

4. Shell Programming and Scripting

In vi editor I want to replace next line char by space

in vi editor I want to replace next line char by space help me eg: input: 123 123 123 output: 123 123 123 (5 Replies)
Discussion started by: RahulJoshi
5 Replies

5. UNIX for Advanced & Expert Users

How to cut a line that contains two different separator

Hi all, I have a script that receives a file, receives the values and put them on an oracle database. I need to do this for multiple files that will contain in the end near 500 million records, so performance is a major concern. until now there was no issue because the file I'm receiving... (2 Replies)
Discussion started by: naoseionome
2 Replies

6. Shell Programming and Scripting

Formatting File having big single line into 95 Char Per Line

Hi All, I have 4 big files which contains one big line containing formatted character records, I need to format each file in such way that each File will have 95 Characters per line. Last line of each file will have newline character at end. Before:- File Name:- File1.dat 102 121340560... (10 Replies)
Discussion started by: lancesunny
10 Replies

7. Shell Programming and Scripting

Match a char with duplicates in a line and replace one of them

Hi, i have a huge file that need to check for a pattern that occur more than once in a line like below:- #lkk>cd-m>A0DV0>192.134.1.1 blablabladsdjsk jshdfskfslfs #lqk>cd-m>A1SV0>192.14.11.1 blalalbnalablab balablablajakjakjakja #pldqw>sf-w>PH67FR>168.55.1.1 balablabala... (5 Replies)
Discussion started by: redse171
5 Replies

8. UNIX for Advanced & Expert Users

File command return wrong filetype while file holds group separator char.

hi, I am trying to get the FileType using the File command. I have one file, which holds Group separator along with ASCII character. It's a Text file. But when I ran the File command the FileType is coming as "data". It should be "ASCII, Text file". Is the latest version of File... (6 Replies)
Discussion started by: Arpitak29
6 Replies

9. Shell Programming and Scripting

How to change the line separator?

Hi All, I have a file with 20 columns, and the data itself has "\n" new line in it. So we have changed the row delimiter to ^E. Now i am unable to use head, wc -l etc... Please let me know how to change the line separator temporarily to run these unix commands. Thanks. (1 Reply)
Discussion started by: baranisachin
1 Replies

10. UNIX for Beginners Questions & Answers

How to replace the field values, which are greater than the specified value with TRUE?

I have a csv file as given below, org1 org2 org3 org4 org5 gene1 100 80 90 80 150 gene2 30 70 50 50 115 gene3 40 120 60 40 105 gene4 20 72 40 60 20 I need to replace the fields are having values greater than 100 with "TRUE". I used the following commands to replace... (6 Replies)
Discussion started by: dineshkumarsrk
6 Replies
Mail::Box::Parser::Perl(3pm)				User Contributed Perl Documentation			      Mail::Box::Parser::Perl(3pm)

NAME
Mail::Box::Parser::Perl - reading messages from file using Perl INHERITANCE
Mail::Box::Parser::Perl is a Mail::Box::Parser is a Mail::Reporter DESCRIPTION
The "Mail::Box::Parser::Perl" implements parsing of messages in Perl. This may be a little slower than the "C" based parser Mail::Box::Parser::C, but will also work on platforms where no C compiler is available. METHODS
Constructors Mail::Box::Parser::Perl->new(OPTIONS) -Option --Defined in --Default file Mail::Box::Parser undef filename Mail::Box::Parser <required> fix_header_errors <false> log Mail::Reporter 'WARNINGS' mode Mail::Box::Parser 'r' trace Mail::Reporter 'WARNINGS' trusted <false> file => FILE-HANDLE filename => FILENAME fix_header_errors => BOOLEAN When header errors are detected, the parsing of the header will be stopped. Other header lines will become part of the body of the message. Set this flag to have the erroneous line added to the previous header line. log => LEVEL mode => OPENMODE trace => LEVEL trusted => BOOLEAN Is the input from the file to be trusted, or does it require extra tests. Related to Mail::Box::new(trusted). The parser $obj->fileChanged() See "The parser" in Mail::Box::Parser $obj->filename() See "The parser" in Mail::Box::Parser $obj->fixHeaderErrors([BOOLEAN]) If set to "true", parsing of a header will not stop on an error, but attempt to add the erroneous this line to previous field. Without BOOLEAN, the current setting is returned. example: $folder->parser->fixHeaderErrors(1); my $folder = $mgr->open('folder', fix_header_errors => 1); $obj->restart() See "The parser" in Mail::Box::Parser $obj->start(OPTIONS) See "The parser" in Mail::Box::Parser $obj->stop() See "The parser" in Mail::Box::Parser Parsing $obj->bodyAsFile(FILEHANDLE [,CHARS [,LINES]]) See "Parsing" in Mail::Box::Parser $obj->bodyAsList([,CHARS [,LINES]]) See "Parsing" in Mail::Box::Parser $obj->bodyAsString([,CHARS [,LINES]]) See "Parsing" in Mail::Box::Parser $obj->bodyDelayed([,CHARS [,LINES]]) See "Parsing" in Mail::Box::Parser $obj->filePosition([POSITION]) See "Parsing" in Mail::Box::Parser $obj->lineSeparator() See "Parsing" in Mail::Box::Parser $obj->popSeparator() See "Parsing" in Mail::Box::Parser $obj->pushSeparator(STRING|REGEXP) See "Parsing" in Mail::Box::Parser $obj->readHeader() $obj->readSeparator(OPTIONS) See "Parsing" in Mail::Box::Parser Internals $obj->closeFile() See "Internals" in Mail::Box::Parser $obj->defaultParserType([CLASS]) Mail::Box::Parser::Perl->defaultParserType([CLASS]) See "Internals" in Mail::Box::Parser $obj->openFile(ARGS) See "Internals" in Mail::Box::Parser $obj->takeFileInfo() See "Internals" in Mail::Box::Parser Error handling $obj->AUTOLOAD() See "Error handling" in Mail::Reporter $obj->addReport(OBJECT) See "Error handling" in Mail::Reporter $obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) Mail::Box::Parser::Perl->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) See "Error handling" in Mail::Reporter $obj->errors() See "Error handling" in Mail::Reporter $obj->log([LEVEL [,STRINGS]]) Mail::Box::Parser::Perl->log([LEVEL [,STRINGS]]) See "Error handling" in Mail::Reporter $obj->logPriority(LEVEL) Mail::Box::Parser::Perl->logPriority(LEVEL) See "Error handling" in Mail::Reporter $obj->logSettings() See "Error handling" in Mail::Reporter $obj->notImplemented() See "Error handling" in Mail::Reporter $obj->report([LEVEL]) See "Error handling" in Mail::Reporter $obj->reportAll([LEVEL]) See "Error handling" in Mail::Reporter $obj->trace([LEVEL]) See "Error handling" in Mail::Reporter $obj->warnings() See "Error handling" in Mail::Reporter Cleanup $obj->DESTROY() See "Cleanup" in Mail::Reporter $obj->inGlobalDestruction() See "Cleanup" in Mail::Reporter DIAGNOSTICS
Warning: File $filename changed during access. When a message parser starts working, it takes size and modification time of the file at hand. If the folder is written, it checks wether there were changes in the file made by external programs. Calling Mail::Box::update() on a folder before it being closed will read these new messages. But the real source of this problem is locking: some external program (for instance the mail transfer agent, like sendmail) uses a different locking mechanism as you do and therefore violates your rights. Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. Warning: Unexpected end of header in $source: $line While parsing a message from the specified source (usually a file name), the parser found a syntax error. According to the MIME specification in the RFCs, each header line must either contain a colon, or start with a blank to indicate a folded field. Apparently, this header contains a line which starts on the first position, but not with a field name. By default, parsing of the header will be stopped. If there are more header lines after the erroneous line, they will be added to the body of the message. In case of new(fix_headers) set, the parsing of the header will be continued. The erroneous line will be added to the preceding field. SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/ LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2012-05-07 Mail::Box::Parser::Perl(3pm)
All times are GMT -4. The time now is 04:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy