Sponsored Content
Top Forums Shell Programming and Scripting Concatenate lines in a single paragraph Post 302316829 by durden_tyler on Saturday 16th of May 2009 08:35:11 PM
Old 05-16-2009
Alternatively, if you have perl then:

Code:
$
$ cat input.txt
Event Type: Warning
Event Source: Sorting
Event Category: None
Event ID: 1188
Date:  9/10/2008
Time:  9:46:50 PM
User:  Adminis\P1
Computer: MyComp-KKL
Description:
User profile MyComp-KKL(S-1-5-21-3230802392-3390281410-1560515013-1307).
$
$ perl -ne '{if (/^(.*):[ ]+(.*)$/) {$x{$1}=$2}
>            elsif (/^User profile/){$p=$_}
> } END {print "In date $x{Date}, $x{Time}. This is a warning from $p"}' input.txt
In date 9/10/2008, 9:46:50 PM. This is a warning from User profile MyComp-KKL(S-1-5-21-3230802392-3390281410-1560515013-1307).
$
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert a paragraph to single line

I need to check the count of pipes on each line of the data to make sure we 4 pipes if its less i need to keep adding the string to form a single line ( Need to join/ concat the below lines until i get the 4 pipes which is end of record ). This fields is basicall a memo where the user would have... (6 Replies)
Discussion started by: rimss
6 Replies

2. UNIX Desktop Questions & Answers

How to concatenate consecutive lines

I have a few lines like -- feature 1, subfeat 0, type 3, subtype 1, value 0, -- feature 1, subfeat 0, type 1, subtype 1, value 0, I would like to concatenate the... (1 Reply)
Discussion started by: shivi707
1 Replies

3. Shell Programming and Scripting

Concatenate two lines in one

Does anyone know a way I can fix my file below where it has lines that are cut? Just like the (notice the space before ms,c=PH).. dn: cn=english,ou=Messaging,ou=lang,o=subject,t=j ms,c=PH which should be dn: cn=english,ou=Messaging,ou=lang,o=subject,t=jms,c=PH The whole text file... (5 Replies)
Discussion started by: Orbix
5 Replies

4. Shell Programming and Scripting

concatenate lines in pairs

Hi, I have a text file with the following contents /C=IT/O=INFN/OU=Personal Certificate/L=Napoli/CN=Some guy /C=IT/O=INFN/CN=INFN CA /O=Grid/O=NorduGrid/OU=uninett.no/CN=Another guy /O=Grid/O=NorduGrid/CN=NorduGrid Certification Authority /C=TW/O=AP/OU=GRID/CN=Someone else... (5 Replies)
Discussion started by: kerl
5 Replies

5. Shell Programming and Scripting

Concatenate lines between lines starting with a specific pattern

Hi, I have a file such as: --- >contig00001 length=35524 numreads=2944 gACGCCGCGCGCCGCGGCCAGGGCTGGCCCA CAGGCCGCGCGGCGTCGGCTGGCTGAG >contig00002 length=4242 numreads=43423 ATGCCGAAGGTCCGCCTGGGGCTGG CGCCGGGAGCATGTAGCG --- I would like to concatenate the lines not starting with ">"... (9 Replies)
Discussion started by: s052866
9 Replies

6. Shell Programming and Scripting

How to search for multiple lines and put them into one paragraph?

Dear all, I'm trying to manipulate a data file and putting a certain lines into one paragraph. What am I actually want to do is that search some lines in a data file. These lines begin with "1\1\GINC-" and end with "\\@" or the following two empty lines as shown in blue. A part of the text... (11 Replies)
Discussion started by: liuzhencc
11 Replies

7. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

8. Programming

Concatenate two lines in a fIle

Hi All, Can any one help me in finding the solution for concatenating two or more lines in a file and writing them to a temporary file. for Example: He is a wise student. So he got first rank. This is in a file i want the output as He is a wise student so he got first rank. into a file... (3 Replies)
Discussion started by: uday.sena.m
3 Replies

9. UNIX for Dummies Questions & Answers

Concatenate three lines into one

Hi. I'm new to this forum. I am attempting to parse an Audit Log from Cognos/TM1, selecting only Event IDs of "client" which are found on the "start-tag" record. These Logs are in a pseudo-XML format but not a true XML format. I want to FTP an Audit Log File from the Cognos server to our UNIX... (7 Replies)
Discussion started by: FredAtArrow
7 Replies

10. Shell Programming and Scripting

Join Lines every paragraph in a file.txt

Hi all, Is there any idea on how to automate convert the paragraph in one line in a file, this will happen after OCR the documents, OCR split every paragraph. I need to join all the paragraph in one line. #cat file.txtThe Commission on Higher Education (CHED) was created through Republic Act... (7 Replies)
Discussion started by: lxdorney
7 Replies
Event::MakeMaker(3pm)					User Contributed Perl Documentation				     Event::MakeMaker(3pm)

NAME
Event::MakeMaker - MakeMaker glue for the C-level Event API SYNOPSIS
This is an advanced feature of Event. DESCRIPTION
For optimal performance, hook into Event at the C-level. You'll need to make changes to your "Makefile.PL" and add code to your "xs" / "c" file(s). WARNING
When you hook in at the C-level you get a huge performance gain, but you also reduce the chances that your code will work unmodified with newer versions of "perl" or "Event". This may or may not be a problem. Just be aware, and set your expectations accordingly. HOW TO
Makefile.PL use Event::MakeMaker qw(event_args); # ... set up %args ... WriteMakefile(event_args(%args)); XS #include "EventAPI.h" BOOT: I_EVENT_API("YourModule"); API (v21) struct EventAPI { I32 Ver; /* EVENTS */ void (*queue )(pe_event *ev); void (*start )(pe_watcher *ev, int repeat); void (*now )(pe_watcher *ev); void (*stop )(pe_watcher *ev, int cancel_events); void (*cancel )(pe_watcher *ev); void (*suspend )(pe_watcher *ev); void (*resume )(pe_watcher *ev); /* All constructors optionally take a stash and template. Either or both can be NULL. The template should not be a reference. */ pe_idle *(*new_idle )(HV*, SV*); pe_timer *(*new_timer )(HV*, SV*); pe_io *(*new_io )(HV*, SV*); pe_var *(*new_var )(HV*, SV*); pe_signal *(*new_signal)(HV*, SV*); /* TIMEABLE */ void (*tstart)(pe_timeable *); void (*tstop)(pe_timeable *); /* HOOKS */ pe_qcallback *(*add_hook)(char *which, void *cb, void *ext_data); void (*cancel_hook)(pe_qcallback *qcb); /* STATS */ void (*install_stats)(pe_event_stats_vtbl *esvtbl); void (*collect_stats)(int yes); pe_ring *AllWatchers; /* TYPEMAP */ SV *(*watcher_2sv)(pe_watcher *wa); void *(*sv_2watcher)(SV *sv); SV *(*event_2sv)(pe_event *ev); void *(*sv_2event)(SV *sv); }; EXAMPLE static pe_io *X11_ev=0; static void x_server_dispatch(void *ext_data) { ... } if (!X11_ev) { X11_ev = GEventAPI->new_io(0,0); X11_ev->poll = PE_R; sv_setpv(X11_ev->base.desc, "X::Server"); X11_ev->base.callback = (void*) x_server_dispatch; X11_ev->base.ext_data = <whatever>; X11_ev->base.prio = PE_PRIO_NORMAL; } X11_ev->fd = x_fd; GEventAPI->resume((pe_event*) X11_ev); GEventAPI->start((pe_event*) X11_ev, 0); BUT I NEED A NEW TYPE OF WATCHER FOR MY INTERGALACTIC INFEROMETER I'd prefer not to export the entire Event.h apparatus in favor of minimizing interdependencies. If you really, really need to create a new type of watcher send your problem analysis to the mailing list! perl v5.14.2 2007-05-22 Event::MakeMaker(3pm)
All times are GMT -4. The time now is 08:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy