re-arranging fields in a file

re-arranging fields in a file

Post by Simon Casa » Sat, 03 Dec 1994 01:36:57



: I've got a bit of a problem that I need resolved.
: I've got a file in the following format :

: -
: r1field1    r1field2    r1field3    r1field4    .....
: r2field1    r2field2    r2field3    r2field4    .....
: -

: and I need it in the format  :

: -
: r1field1
: r1field2
: r1field3
: r1field4
: .
: .
: .
: .

: r2field1
: r2field2
: r2field3
: r2field4
: .
: .
: .
: .
: -

: Can anybody help me?

: Thanks very much in advance.

if the fields are whitespace separated and in the proper order
tr -s '         ' '\012' < input > output
will translate all blanks and tabs ( the first ' ' contains a blank and
a tab) into a single line feed.

: <-------------------------------------------------------------------->
: | Toby Blake                            Public Health Sciences,      |
: |                                       Edinburgh University,        |

 
 
 

re-arranging fields in a file

Post by Vadivelu Elumal » Thu, 08 Dec 1994 09:47:03



!: I've got a bit of a problem that I need resolved.
!: I've got a file in the following format :

!: r1field1    r1field2    r1field3    r1field4    .....
!: r2field1    r2field2    r2field3    r2field4    .....

!: and I need it in the format  :

!: r1field1
!: r1field2
!: r1field3
!: r1field4
!: .
!: r2field1
!: r2field2
!: r2field3
!: r2field4
!: .
!if the fields are whitespace separated and in the proper order
!tr -s '        ' '\012' < input > output
!will translate all blanks and tabs ( the first ' ' contains a blank and
!a tab) into a single line feed.

        Don't worry about order and number of fields.  Following perl
script should be robust enough:

        perl -ne 's/\s+/\n/g ; print'  <filename>



 
 
 

re-arranging fields in a file

Post by Farook Wad » Fri, 09 Dec 1994 07:15:30






>!: I've got a bit of a problem that I need resolved.
>!: I've got a file in the following format :

>!: r1field1    r1field2    r1field3    r1field4    .....
>!: r2field1    r2field2    r2field3    r2field4    .....

>!: and I need it in the format  :

>!: r1field1
>!: r1field2
>!: r1field3
>!: r1field4
>!: .
>!: r2field1
>!: r2field2
>!: r2field3
>!: r2field4
>!: .
>!if the fields are whitespace separated and in the proper order
>!tr -s '    ' '\012' < input > output
>!will translate all blanks and tabs ( the first ' ' contains a blank and
>!a tab) into a single line feed.

>    Don't worry about order and number of fields.  Following perl
>script should be robust enough:

>    perl -ne 's/\s+/\n/g ; print'  <filename>



How about:

cat <filename> | nawk '{for (i=1;i <= NF; i++) printf("%s\n",$i); printf("\n\n")}'

Farook.
--
**********************************************************
* Farook Wadia, System-Software Programmer, SoftQuad Inc.*
* SOFTQUAD INC. DOES NOT OWN OR SHARE MY OPINION         *
**********************************************************

 
 
 

1. re-arranging fields in a file

I've got a bit of a problem that I need resolved.
I've got a file in the following format :

-
r1field1    r1field2    r1field3    r1field4    .....
r2field1    r2field2    r2field3    r2field4    .....
-

and I need it in the format  :

-
r1field1
r1field2
r1field3
r1field4
.
.
.
.

r2field1
r2field2
r2field3
r2field4
.
.
.
.
-

Can anybody help me?

Thanks very much in advance.

<-------------------------------------------------------------------->
| Toby Blake                            Public Health Sciences,      |
|                                       Edinburgh University,        |

<-------------------------------------------------------------------->

2. Ports im Masquerading - Timeouts

3. Re-arranging partitions...

4. ,,~~Advice For New Immigrants~~...

5. File System Arranging - Need Advice

6. User and Group Permissions

7. How are the files on the BSD CD-ROMs arranged ?

8. Add User

9. How do you arrange the sequence of commands in the .login file

10. Netscape plug-ins, helper files, Acrobat etc.

11. Compare file modification date using tcsh built-ins

12. How do I extract a field between two other fields?

13. Help - sending with mailx to bcc field instead of to: field