drop every newline in file and then ... 
Author Message
 drop every newline in file and then ...

Helo.

    Any ideas how to remove all newline character from text file and then
insert newline before string "OP" ?

i.e.

OP1234565
45654654OP12345

result

OP123456545654
OP12345

    GG



Sun, 02 Nov 2003 20:35:30 GMT  
 drop every newline in file and then ...

Quote:

>Helo.

>    Any ideas how to remove all newline character from text file and then
>insert newline before string "OP" ?

>i.e.

>OP1234565
>45654654OP12345

>result

>OP123456545654
>OP12345

BEGIN { ORS="" }
gsub(/OP/,"\n&")+5


Sun, 02 Nov 2003 21:01:31 GMT  
 drop every newline in file and then ...

Kenny McCormack napisa3(a) w wiadomo?ci:

Quote:
>>OP1234565
>>45654654OP12345

>>result

>>OP123456545654
>>OP12345

>BEGIN { ORS="" }
>gsub(/OP/,"\n&")+5

Thank You, but could You please give me some comments ,especially about '+5'
Regards.

    GG



Sun, 02 Nov 2003 21:30:59 GMT  
 drop every newline in file and then ...
% Thank You, but could You please give me some comments ,especially about '+5'

It's short for ||1

--

Patrick TJ McPhee
Knightsbridge SW7



Mon, 03 Nov 2003 01:54:24 GMT  
 drop every newline in file and then ...

Quote:


...
>>OP1234565
>>45654654OP12345

>>result

>>OP123456545654
>>OP12345

>BEGIN { ORS="" }
>gsub(/OP/,"\n&")+5

How to make awk less readable than Perl!

If the input starts with OP, the output starts with a newline, and there's
no newline at the end of the file. If there shouldn't be a blank line at the
top but should be an ending newline, it's more complicated.

BEGIN { ORS = "" }
{ gsub(/OP/, "\n&"); if (NR == 1) sub(/^\n/, ""); print }
END { print "\n" }



Mon, 03 Nov 2003 07:11:59 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. every odd newline drop

2. Substituting :: for __ in every htm file, and rename htlml file

3. PEP 259: Omit printing newline after newline

4. PEP 259: Omit printing newline after newline

5. update every second or every resched()?

6. File Drop Combo with ODBC file

7. File Filed Drop List Problems

8. How to remove newlines in text file

9. deleting newline from last line in file

10. Remove trailing newlines from file

11. newline in gawk program file

12. Behavior of newline character in ANS Forth, using WRITE-FILE

 

 
Powered by phpBB® Forum Software