aplit line - one liner 
Author Message
 aplit line - one liner

Hi
I have used simple one liners with awk for a multitude of cases but can
someone help me with this please
I have a file containing;

MPC, 10, 806613, 3, -1.0, 700630, 3, 0.5, , , ,700632, 3, 0.5

and I want to split it to

MPC, 10, 806613, 3, -1.0, 700630, 3, 0.5, ,
, ,700632, 3, 0.5

how can I do this ?

Thanks
Ian

--

DCH Consultancy Ltd.               http://www.*-*-*.com/
Goslings, Manor Farm, West Coker  Tel: +44 (0)1935 862 081
Somerset, England, BA22 9DT       Fax: +44 (0)1935 864 131



Sun, 07 Apr 2002 03:00:00 GMT  
 aplit line - one liner
Hi

Not to worry just found out, bet there is a slicker way

awk '{print $1, $2, $3, $4, $5, $6, $7, $8, $9,"\n",$10, $11, $12, $13}'
mac2

obvious really::))

Ian

Quote:

> Hi
> I have used simple one liners with awk for a multitude of cases but can
> someone help me with this please
> I have a file containing;

> MPC, 10, 806613, 3, -1.0, 700630, 3, 0.5, , , ,700632, 3, 0.5

> and I want to split it to

> MPC, 10, 806613, 3, -1.0, 700630, 3, 0.5, ,
> , ,700632, 3, 0.5

> how can I do this ?

> Thanks
> Ian

> --

> DCH Consultancy Ltd.             http://www.dch-consultancy.com
> Goslings, Manor Farm, West Coker  Tel: +44 (0)1935 862 081
> Somerset, England, BA22 9DT       Fax: +44 (0)1935 864 131

--

DCH Consultancy Ltd.              http://www.dch-consultancy.com
Goslings, Manor Farm, West Coker  Tel: +44 (0)1935 862 081
Somerset, England, BA22 9DT       Fax: +44 (0)1935 864 131


Sun, 07 Apr 2002 03:00:00 GMT  
 aplit line - one liner


Quote:
>Hi

>Not to worry just found out, bet there is a slicker way

>awk '{print $1, $2, $3, $4, $5, $6, $7, $8, $9,"\n",$10, $11, $12, $13}'
>mac2

>obvious really::))

That puts a space before and after the newline.
Lose the commas around the "\n" and you'll lose the spaces around
the newline.

awk '{print $1, $2, $3, $4, $5, $6, $7, $8, $9 "\n" $10, $11, $12, $13}'

but if a space on the end of the line is ok, consider:

awk '{$10="\n" $10;print}'

or to do it without any spaces, use something like this:

awk '{a=$10; $10=""; $9=$9 "\n" a; print}' infile

Chuck Demas
Needham, Mass.

Quote:

>Ian


>> Hi
>> I have used simple one liners with awk for a multitude of cases but can
>> someone help me with this please
>> I have a file containing;

>> MPC, 10, 806613, 3, -1.0, 700630, 3, 0.5, , , ,700632, 3, 0.5

>> and I want to split it to

>> MPC, 10, 806613, 3, -1.0, 700630, 3, 0.5, ,
>> , ,700632, 3, 0.5

>> how can I do this ?

>> Thanks
>> Ian

>> --

>> DCH Consultancy Ltd.             http://www.dch-consultancy.com
>> Goslings, Manor Farm, West Coker  Tel: +44 (0)1935 862 081
>> Somerset, England, BA22 9DT       Fax: +44 (0)1935 864 131

>--

>DCH Consultancy Ltd.              http://www.dch-consultancy.com
>Goslings, Manor Farm, West Coker  Tel: +44 (0)1935 862 081
>Somerset, England, BA22 9DT       Fax: +44 (0)1935 864 131

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

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



Sun, 07 Apr 2002 03:00:00 GMT  
 aplit line - one liner

Quote:

> That puts a space before and after the newline.
> Lose the commas around the "\n" and you'll lose the spaces around
> the newline.

Sharp eyes.  Good work.

Nicki



Sun, 07 Apr 2002 03:00:00 GMT  
 aplit line - one liner

Quote:


>> That puts a space before and after the newline.
>> Lose the commas around the "\n" and you'll lose the spaces around
>> the newline.

>Sharp eyes.  Good work.

>Nicki

Thanks.

Those eyes need stronger and stronger reading glasses nowadays.  8~(

Chuck Demas
Needham, Mass.

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

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



Sun, 07 Apr 2002 03:00:00 GMT  
 aplit line - one liner
All,

Thanks to all, another one for my one-line black book of awk's.

Nice to see users of a newsgroup provide help w/o spinning off into
non-related threads.

Thanks again

Ian

--

DCH Consultancy Ltd.              http://www.dch-consultancy.com
Goslings, Manor Farm, West Coker  Tel: +44 (0)1935 862 081
Somerset, England, BA22 9DT       Fax: +44 (0)1935 864 131



Mon, 08 Apr 2002 03:00:00 GMT  
 aplit line - one liner
Chuck responded, with a tear in his eye:

Quote:
> Nicki complimented:
> > Chuck advised:
> > > Lose the commas around the "\n" and you'll lose the
> > > spaces around the newline.

> > Sharp eyes. Good work.

> Thanks.

> Those eyes need stronger and stronger reading glasses nowadays. 8~(

When did you two kiss 'n' make up?

First she pryed your age out of you. Next she'll concoct some ruse
to determine your marital status. Soon we'll have our first
comp.lang.awk wedding. Joy!

--
Jim Monty

Tempe, Arizona USA



Mon, 08 Apr 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. one liner? --- split file at empty line

2. How to replace one or two words with one word with one line of awk code

3. APL one-liner needed for new novel

4. J One Liners

5. one liner awk

6. One.liner

7. Looking for AWK/SED one-liners

8. One Liners

9. LOGO-L> One-liners :-)

10. LOGO-L> one-liners

11. LOGO-L> one-liner

12. LOGO-L> Re: one-liners

 

 
Powered by phpBB® Forum Software