Sponsored Content
Top Forums Shell Programming and Scripting any savant ? using AWK/SED to remove newline character between two strings : conditional removal Post 302501184 by sieger007 on Wednesday 2nd of March 2011 10:46:23 PM
Old 03-02-2011
Question

That was very helpful except for the fact that it does not 'think' like this .
What I am trying to do is getting rid of the newline characters - that erroneously break the word and make things incoherent.
LOGIC:


-- Go Find a String1
---Look for the nth instance of String1
-- From the nth instance onwards , excluding string1 : `do this stuff`
-- Keep doing till you come to the 'm th' instance of string 2 , excluding String2.
The above was a brilliant idea , except for the fact that I cannot gurantee that there is a paragraph in every file , that can be used as line separator
So your looking at something like this :



Code:
Begin Transaction ;
She sells
sea shells
by
the
sea shore
End Transaction ;
Begin Transaction ;
For if she sells sea-shells on the sea-shore
 Then I'm sure she sells sea-shore shells.
End transaction ;
Begin Transaction ;
The shells sh
e sells a
re sea-sh
ells, I'm s
ure.
replace function ()
Blah

Output should be :

Code:
Begin Transaction ;
She sells
sea shells
by
the
sea shore
End Transaction ;
Begin Transaction ;
For if she sells sea-shells on the sea-shore
 Then I'm sure she sells sea-shore shells.
End transaction ;
Begin Transaction ;
The shells she sells are sea-shells, I'm sure.
replace function ()
Blah

.The above AWK gives this o/p

Code:
Begin Transaction ;
She sells
sea shells
by
the
sea shore
End Transaction ;
Begin Transaction ;
For if she sells sea-shells on the sea-shore
 Then I'm sure she sells sea-shore shells.
End transaction ;
/* there is no newline char after the begin transaction below. It shd be there * /
Begin Transaction ;The shells she sells are sea-shells, I'm sure.
replace function ()
Blah

THANKS for your help
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Special Character SED/AWK removal

I have a script that produces an output containing '/.ssh'. I am trying to find a way of parsing only this data from a single line, without removing any other special characters contained within the output as a result of the parse. Any help would be appreciated (6 Replies)
Discussion started by: Raggedranger333
6 Replies

2. Shell Programming and Scripting

sed/awk remove newline

Hi, I have input file contains sql queries i need to eliminate newlines from it. when i open it vi text editor and runs :%s/'\n/'/g it provides required result. but when i run sed command from shell prompt it doesn't impact outfile is still same as inputfile. shell] sed -e... (6 Replies)
Discussion started by: mirfan
6 Replies

3. Shell Programming and Scripting

sed help with character removal

Hello I've got a string of text with a number in pence, e.g. 0.52p, I need to remove the 'p' so that it just reads 0.52 without of course removing all the other 'p' characters. Many thanks (1 Reply)
Discussion started by: mrpugster
1 Replies

4. Shell Programming and Scripting

Remove newline character between two delimiters

hi i am having delimited .dat file having content like below. test.dat(5 line of records) ====== PT2~Stag~Pt2 Stag Test. Updated~PT2 S T~Area~~UNCEF R20~~2012-05-24 ~2014-05-24~~ PT2~Stag y~Pt2 Stag Test. Updated~PT2 S T~Area~METR~~~2012-05-24~2014-05-24~~test PT2~Pt2 Stag Test~~PT2 S... (4 Replies)
Discussion started by: sushine11
4 Replies

5. Shell Programming and Scripting

awk or sed script to remove strings

Below am trying to separate FA-7A:1, In output file it should display 7A 1 Command am using Gives same output as below format: 22B7 10000000c9720873 0 22B7 10000000c95d5d8b 0 22BB 10000000c97843a2 0 22BB 10000000c975adbd 0 Not showing FA ports as required format... (5 Replies)
Discussion started by: aix_admin_007
5 Replies

6. Shell Programming and Scripting

Want to remove / and character using awk or sed

Below i am trying to remove "/" and "r" from the output, so i need output as: hdiskpower3 hdisk0 hdisk1 #inq | grep 5773 | awk '{print $1}' | sed 's/dev//g' | awk -F"/" '{$1=$1}1' .....................................................//rhdiskpower0 //rhdiskpower1 //rhdiskpower2... (3 Replies)
Discussion started by: aix_admin_007
3 Replies

7. Shell Programming and Scripting

Remove last newline character..

Hi all.. I have a text file which looks like below: abcd efgh ijkl (blank space) I need to remove only the last (blank space) from the file. When I try wc -l the file name,the number of lines coming is 3 only, however blank space is there in the file. I have tried options like... (14 Replies)
Discussion started by: Sathya83aa
14 Replies

8. UNIX for Dummies Questions & Answers

Extracting 22-character strings from text using sed/awk?

Here is my task, I feel sure this can be accomplished with see/awk but can't seem to figure out how. I have large flat file from which I need to extract every case of a pairing of characters (GG) in this case PLUS the previous 20 characters. The output should be a list (which I plan to make... (17 Replies)
Discussion started by: Twinklefingers
17 Replies

9. Shell Programming and Scripting

How to remove certain character strings with awk?

Hi all, I need to remove DBPATH= and /db from the string below using awk (or sed, as it also exists on the machine). Input: DBPATH=/some/path/database/db Desired output: /some/path/database Thank you! (8 Replies)
Discussion started by: ejianu
8 Replies

10. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies
Mojo::Transaction(3pm)					User Contributed Perl Documentation				    Mojo::Transaction(3pm)

NAME
Mojo::Transaction - Transaction base class SYNOPSIS
use Mojo::Base 'Mojo::Transaction'; DESCRIPTION
Mojo::Transaction is an abstract base class for transactions. EVENTS
Mojo::Transaction can emit the following events. "connection" $tx->on(connection => sub { my ($tx, $connection) = @_; ... }); Emitted when a connection has been assigned to transaction. "finish" $tx->on(finish => sub { my $tx = shift; ... }); Emitted when transaction is finished. "resume" $tx->on(resume => sub { my $tx = shift; ... }); Emitted when transaction is resumed. ATTRIBUTES
Mojo::Transaction implements the following attributes. "kept_alive" my $kept_alive = $tx->kept_alive; $tx = $tx->kept_alive(1); Connection has been kept alive. "local_address" my $local_address = $tx->local_address; $tx = $tx->local_address($address); Local interface address. "local_port" my $local_port = $tx->local_port; $tx = $tx->local_port($port); Local interface port. "previous" my $previous = $tx->previous; $tx = $tx->previous(Mojo::Transaction->new); Previous transaction that triggered this followup transaction. # Path of previous request say $tx->previous->req->url->path; "remote_address" my $remote_address = $tx->remote_address; $tx = $tx->remote_address($address); Remote interface address. "remote_port" my $remote_port = $tx->remote_port; $tx = $tx->remote_port($port); Remote interface port. "req" my $req = $tx->req; $tx = $tx->req(Mojo::Message::Request->new); HTTP 1.1 request, defaults to a Mojo::Message::Request object. "res" my $res = $tx->res; $tx = $tx->res(Mojo::Message::Response->new); HTTP 1.1 response, defaults to a Mojo::Message::Response object. METHODS
Mojo::Transaction inherits all methods from Mojo::EventEmitter and implements the following new ones. "client_close" $tx->client_close; Transaction closed. "client_read" $tx->client_read($chunk); Read and process client data. Meant to be overloaded in a subclass. "client_write" my $chunk = $tx->client_write; Write client data. Meant to be overloaded in a subclass. "connection" my $connection = $tx->connection; $tx = $tx->connection($connection); Connection identifier or socket. "error" my $message = $tx->error; my ($message, $code) = $tx->error; Parser errors and codes. "is_finished" my $success = $tx->is_finished; Check if transaction is finished. "is_websocket" my $false = $tx->is_websocket; False. "is_writing" my $success = $tx->is_writing; Check if transaction is writing. "resume" $tx = $tx->resume; Resume transaction. "server_close" $tx->server_close; Transaction closed. "server_read" $tx->server_read($chunk); Read and process server data. Meant to be overloaded in a subclass. "server_write" my $chunk = $tx->server_write; Write server data. Meant to be overloaded in a subclass. "success" my $res = $tx->success; Returns the Mojo::Message::Response object ("res") if transaction was successful or "undef" otherwise. Connection and parser errors have only a message in "error", 400 and 500 responses also a code. # Sensible exception handling if (my $res = $tx->success) { say $res->body; } else { my ($message, $code) = $tx->error; if ($code) { say "$code $message response."; } else { say "Connection error: $message"; } } Error messages can be accessed with the "error" method of the transaction object. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Transaction(3pm)
All times are GMT -4. The time now is 03:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy