any savant ? using AWK/SED to remove newline character between two strings : conditional removal
I'd like to remove (do a pattern or precise replacement - this I can handle in SED using Regex )
---AFTER THE 1ST Occurrence ( i.e. on the 2nd occurrence - from the 2nd to fourth occurance ) of a specific string : type 1
-- After the 1st occurrence of 1 string1 till the 1st occurrence of string2 not counting the latter.
e.g.
/* Notice How I made the above English incoherent by putting newline breaking words, those newline need to go */
End Transaction ;
- How do I go about knocking of the newline char between Last Begin and End transaction pair
Program Thought : Go find the 3rd Begin transaction statement and knock off the newline until the 1st end transaction statement
Moderator's Comments:
Please use [code] and [/code] tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks.
Last edited by zaxxon; 03-02-2011 at 03:50 AM..
Reason: code tags
Both the 2nd solution here and bartus11's post above rely on a blank line after the End line. Unlike Bartus11's solution the 2nd solution here ensures the Beg and End lines aren't joined up with the rest of the text, and restores the blank line after then End line.
Last edited by Chubler_XL; 03-02-2011 at 11:23 PM..
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 :
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)