Removal of a linefeed in 
Author Message
 Removal of a linefeed in

Is there anyone who has done a removal of a linefeed with awk i UNIX
(HP-UX).
My problem is as follows.
I've got a fil looking like this:

any text at all -
     continuing text1
any text at all -
     continuing text2
any text at all -
     continuing text3
...

I would like to have a result looking like this:

any text at all continuing text1
any text at all continuing text2
any text at all continuing text3
...

Is it possible to do this with awk???

Thanks for any help I can get

Juha



Sat, 25 Nov 2000 03:00:00 GMT  
 Removal of a linefeed in


Quote:

>Is there anyone who has done a removal of a linefeed with awk i UNIX
>(HP-UX).
>My problem is as follows.
>I've got a fil looking like this:

>any text at all -
>     continuing text1
>any text at all -
>     continuing text2
>any text at all -
>     continuing text3
>...

>I would like to have a result looking like this:

>any text at all continuing text1
>any text at all continuing text2
>any text at all continuing text3
>...

>Is it possible to do this with awk???

If you wish to eliminate the linefeeds on odd lines, try this:

awk 'NR%2==1{printf "%s",$0;next}{print}' infile > outfile

on your example, unfortunately, this produces:

any text at all -     continuing text1
any text at all -     continuing text2
any text at all -     continuing text3

in the example above, this would work:

awk '/ -$/{printf "%s",substr($0,1,length -2)} \
/^  */{for (i=1;i<NF;i++){printf " %s",$i};print " " $NF}' temp

in gawk, or awks that support the sub function, one could write:

gawk '/-$/{sub(/-$/,"");a=$0} \
/^  */{sub(/^ */,"");b=$0;print a b}' infile

or

gawk '/-$/ {sub(/-$/,"");printf "%s",$0} \
/^  */ {sub(/^ */,"");print}' infile

These ought too give you enough to play with to solve whatever
your real problem is.

Chuck Demas
Needham, Mass.

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Sun, 26 Nov 2000 03:00:00 GMT  
 Removal of a linefeed in

Try something like this untested snippet (intended for gawk):

BEGIN {RS="-\n[[:space:]]*"; ORS="";}
        {print}

Let me know how it works.  By the way, are you trying to
de-continuize a VMS command file?

                                        -- WB

In comp.lang.awk, on 10 Jun 1998 20:33:08 GMT,

Quote:



>>Is there anyone who has done a removal of a linefeed with awk i UNIX
>>(HP-UX).
>>My problem is as follows.
>>I've got a fil looking like this:

>>any text at all -
>>     continuing text1
>>any text at all -
>>     continuing text2
>>any text at all -
>>     continuing text3
>>...

>>I would like to have a result looking like this:

>>any text at all continuing text1
>>any text at all continuing text2
>>any text at all continuing text3
>>...

>>Is it possible to do this with awk???

>If you wish to eliminate the linefeeds on odd lines, try this:

>awk 'NR%2==1{printf "%s",$0;next}{print}' infile > outfile

>on your example, unfortunately, this produces:

>any text at all -     continuing text1
>any text at all -     continuing text2
>any text at all -     continuing text3

>in the example above, this would work:

>awk '/ -$/{printf "%s",substr($0,1,length -2)} \
>/^  */{for (i=1;i<NF;i++){printf " %s",$i};print " " $NF}' temp

>in gawk, or awks that support the sub function, one could write:

>gawk '/-$/{sub(/-$/,"");a=$0} \
>/^  */{sub(/^ */,"");b=$0;print a b}' infile

>or

>gawk '/-$/ {sub(/-$/,"");printf "%s",$0} \
>/^  */ {sub(/^ */,"");print}' infile

>These ought too give you enough to play with to solve whatever
>your real problem is.

>Chuck Demas
>Needham, Mass.

>--
>  Eat Healthy    |   _ _   | Nothing would be done at all,

>  Die Anyway     |    v    | That no one could find fault with it.




Mon, 27 Nov 2000 03:00:00 GMT  
 Removal of a linefeed in



Quote:
> Is there anyone who has done a removal of a linefeed with awk i UNIX
> (HP-UX).
> My problem is as follows.
> I've got a fil looking like this:

> any text at all -
>      continuing text1
> any text at all -
>      continuing text2
> any text at all -
>      continuing text3
> ...

> I would like to have a result looking like this:

> any text at all continuing text1
> any text at all continuing text2
> any text at all continuing text3
> ...

> Is it possible to do this with awk???

> Thanks for any help I can get

> Juha

You can probably use sed to delete the end of lines using the N command
Ex:
/pattern/  (this finds pattern)
N (this reads in next line)
s/ *\n / / (this joins line and replaces end of line with space)
s/$/\ (this puts back in the end of line for the newly created line. You
have to hit /       enter at end)

Mamoon R. Ansari
Systems Administrator
IT Data Solutions
Michigan Tech University



Mon, 04 Dec 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. replacing ^M characters with linefeed

2. linefeeds in sed

3. C3.1 Dos Printer LINEFEED Problem

4. Document editor that strips linefeeds?

5. Binary output to stdout without linefeeds, possible?

6. How do I parse with respect to a Linefeed character

7. RDE linefeeds

8. Carriage Return without a linefeed on Win95?

9. Linefeed in Unix files

10. Linefeed Character

11. Newline (linefeed) suppress.

12. No Linefeed on Text Screen using Backspace?

 

 
Powered by phpBB® Forum Software