awk problem 
Author Message
 awk problem

Hi Guys!
I try to use awk to take away \n but it isn't working is somone know why

What I want do is

the input file is like
mux_42
mux_43
mux_44
mux_45
mux_46
mux_47
mux_48
mux_49
mux_50
mux_51
mux_52
mux_53
mux_78

I want have the out put like

mux_42 mux_43 mux_44 mux_45 mux_46 .....
no \n

what i do I try to set -F to " "
but this not working

any one kno why

 cat muxfile  | awk -F' ' '{ print $0}'



Sun, 09 Jan 2000 03:00:00 GMT  
 awk problem


Quote:
>Hi Guys!
>I try to use awk to take away \n but it isn't working is somone know why

>What I want do is

>the input file is like
>mux_42
>mux_43
>mux_44
>mux_45
>mux_46
>mux_47
>mux_48
>mux_49
>mux_50
>mux_51
>mux_52
>mux_53
>mux_78

>I want have the out put like

>mux_42 mux_43 mux_44 mux_45 mux_46 .....
>no \n

tr -d '\n' < file > file.new

************************************************************************
"I'd love to go out with you, but I'm taking punk totem pole carving."


          hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer



Sun, 09 Jan 2000 03:00:00 GMT  
 awk problem

Excerpts from netnews.comp.lang.awk: 23-Jul-97 Re: awk problem by Jeremy

Quote:

> >I want have the out put like

> >mux_42 mux_43 mux_44 mux_45 mux_46 .....
> >no \n

> tr -d '\n' < file > file.new

A minor point, but the above command will concatenate all lines
WITHOUT any intervening space.  The following command will work however:

tr '\n' ' ' <file >file.new

 - Bala
   [ just being picky ;-) ]



Sun, 09 Jan 2000 03:00:00 GMT  
 awk problem

: Hi Guys!
: I try to use awk to take away \n but it isn't working is somone know why

: What I want do is

: the input file is like
: mux_42
: mux_43
: mux_44
: mux_45
: mux_46
: mux_47
: mux_48
: mux_49
: mux_50
: mux_51
: mux_52
: mux_53
: mux_78

: I want have the out put like

: mux_42 mux_43 mux_44 mux_45 mux_46 .....
: no \n

: what i do I try to set -F to " "
: but this not working

: any one kno why

:  cat muxfile  | awk -F' ' '{ print $0}'

awk '$1 { printf("%s ",$0) }' muxfile

Q+D : prints line if a word exists, with a trailing space...
--
*what the h[e,a]ck? it's -grg-*



Sun, 09 Jan 2000 03:00:00 GMT  
 awk problem

Excerpts from netnews.comp.lang.awk: 23-Jul-97 awk problem by Djavad

Quote:
>Hi Guys!
>I try to use awk to take away \n but it isn't working is somone know why

>What I want do is

>the input file is like
>mux_42
>mux_43
>mux_44
>mux_45
>mux_46
>mux_47
>mux_48
>mux_49
>mux_50
>mux_51
>mux_52
>mux_53
>mux_78

>I want have the out put like

>mux_42 mux_43 mux_44 mux_45 mux_46 .....
>no \n

>what i do I try to set -F to " "
>but this not working

>any one kno why

> cat muxfile  | awk -F' ' '{ print $0}'

You need to set FS to newline and ORS to a space to accomplish what you
want.  The following command has been tested under unix:

$ awk 'BEGIN {FS = "\n" ; ORS = " "}; {print $0}' infile > outfile

Hope this helps,

 - Bala



Sun, 09 Jan 2000 03:00:00 GMT  
 awk problem

Hi,

Using Gnu Awk (gawk) 3.0, patchlevel 0 under DOS/Windows
Using Gnu Awk (gawk) 2.15, patchlevel 3 under Unix

the following works a treat
        gawk 1 ORS= filename
or
        type[cat] filename | gawk 1 ORS=

Unix awk/nawk :-( require the more long-winded '{print}' in place of the
sweetly succinct 1 but otherwise are fine.

Hope it helps
Barrie
--------------------------------



Quote:
> Hi Guys!
> I try to use awk to take away \n but it isn't working is somone know why

> What I want do is

> the input file is like
> mux_42
> mux_43
...
> mux_78

> I want have the out put like

> mux_42 mux_43 mux_44 mux_45 mux_46 .....
> no \n

> what i do I try to set -F to " "
> but this not working

> any one kno why

>  cat muxfile  | awk -F' ' '{ print $0}'



Mon, 10 Jan 2000 03:00:00 GMT  
 awk problem

Quote:

> Hi Guys!
> I try to use awk to take away \n but it isn't working is somone know why What I want do is
> the input file is like
> mux_42
> mux_43
> mux_44
> mux_45
> I want have the out put like > mux_42 mux_43 mux_44 mux_45 mux_46 .....
> no \n

> what i do I try to set -F to " " but this not working any one kno why

You can either reset the ORS (output record separator)
to " " (ie. awk 'BEGIN{ORS=" "}{print $1}END{}' muxfile).

or you could always print them explicitly in a printf statement
(ie. awk'{printf("%s ",$1)}' muxfile).

Either one will give the output you desire.

Steve



Mon, 10 Jan 2000 03:00:00 GMT  
 awk problem


: >Hi Guys!
: >I try to use awk to take away \n but it isn't working is somone know why
: >
: >What I want do is
: >
: >the input file is like
: >mux_42
: >mux_43
: >mux_44
: >mux_45
: >mux_46
: >mux_47
: >mux_48
: >mux_49
: >mux_50
: >mux_51
: >mux_52
: >mux_53
: >mux_78
: >
: >I want have the out put like
: >
: >mux_42 mux_43 mux_44 mux_45 mux_46 .....
: >no \n

: tr -d '\n' < file > file.new

Most tr's I'm familiar with don't understand '\n'.  All
understand '\12'.  However,  I think you meant:

       tr '\12' ' ' < file > file.new

Your version produces the file:

       mux_42mux_43mux_44mux_45mux_46.....

As for the awk question,  print always appends newline.

       printf "%s ",$0

does not.

: ************************************************************************
: "I'd love to go out with you, but I'm taking punk totem pole carving."


:         hundreds, if not thousands, of dollars, every time he posts -
: ************************************************************************
: rwvpf wpnrrj ibf ijrfer

--
Dan Mercer

Opinions expressed herein are my own and may not represent those of my employer.



Mon, 10 Jan 2000 03:00:00 GMT  
 awk problem


% Unix awk/nawk :-( require the more long-winded '{print}' in place of the
% sweetly succinct 1 but otherwise are fine.

I just did this with nawk and it worked fine. print is the default action,
after all.

A simple shell solution to this problem (Bourne-ish shells) would be
 echo `cat filename`
--

Patrick TJ McPhee
East York  Canada



Tue, 11 Jan 2000 03:00:00 GMT  
 awk problem

Quote:

> Hi Guys!
> I try to use awk to take away \n but it isn't working is somone know why

> What I want do is

> the input file is like
> mux_42
> mux_43
> mux_44
> mux_45
> mux_46
> mux_47
> mux_48
> mux_49
> mux_50
> mux_51
> mux_52
> mux_53
> mux_78

> I want have the out put like

> mux_42 mux_43 mux_44 mux_45 mux_46 .....
> no \n

> what i do I try to set -F to " "
> but this not working

> any one kno why

>  cat muxfile  | awk -F' ' '{ print $0}'

 cat muxfile  | awk  '{ printf("%s ",$0}'

Should do it.

--
Paul Watson
WF Software Ltd.
Tel: +44 121 440 3179
Fax: +44 121 440 3806



Tue, 11 Jan 2000 03:00:00 GMT  
 awk problem

Quote:

> I try to use awk to take away \n but it isn't working is somone know why

> What I want do is the input file is like

<snip>

Quote:
> I want have the output like

> mux_42 mux_43 mux_44 mux_45 mux_46 .....
> no \n

Djavad,

An alternative solution:

        echo `cat muxfile`

Has the identical effect, without using awk (appologies for using a
non-awk solution in an awk ng).

Hope it helps, Tim.  ;o)

--
Tim Rigden                                http://www.york.ac.uk/~tcr100/
University of York               Computer Systems & Software Engineering
------------------------------------------------------------------------



Mon, 17 Jan 2000 03:00:00 GMT  
 awk problem



Quote:
>Excerpts from netnews.comp.lang.awk: 23-Jul-97 Re: awk problem by Jeremy

>> >I want have the out put like

>> >mux_42 mux_43 mux_44 mux_45 mux_46 .....
>> >no \n

>> tr -d '\n' < file > file.new

>A minor point, but the above command will concatenate all lines
>WITHOUT any intervening space.  The following command will work however:

>tr '\n' ' ' <file >file.new

Won't xargs accomplish the same thing?

xargs < file > file_new



Sun, 30 Jan 2000 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. awk problem

2. Awk Problem: Changing Input Data Format

3. awk problem sorting and deduping file

4. simple awk problem

5. help with a tricky awk problem...

6. multiple regression using AWK Problem

7. AWK: Problem processing first line

8. awk problem

9. solved awk-problems

10. Small awk problem

11. Sharing a subtle awk problem

12. A shell/awk problem

 

 
Powered by phpBB® Forum Software