About awk
Thanks, Mark. You saved my time. It works for me if I change the initial i to 1 (i=1), because I don't want to get $0 to be the output. *
Greetings,
Marco
On Sun, Aug 19, 2012 at 2:40 AM, mwillson <cdr.nil@gmail.com> wrote:
On Saturday, 18 August 2012 19:40:02 UTC+1, Morning Star *wrote:
> Hi guys,
> I have some string and numeric data in like this format (one line):
> 1 2 3 4 5 6 7 8 9 10 11 12
> and i want the output like this:
> 1 2 3
> 4 5 6
> 7 8 9
> 10 11 12
>
>
>
> How do I do that in awk?*
>
>
> Thanks in advance.
>
>
> Greetings,
>
>
> Marco
Marco,
Does the following work for you?
BEGIN {
* * splitat = 3
}
{
* * for (i = 0; i <= NF; i++) {
* * * * printf("%s ",$i)
* * * * if ((i % splitat) == 0) printf("
")
* * }
}
Put into a file called split.awk and run with "awk -f split.awk your_input_file_name".
-mark
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/6968e875-eea1-4f6a-aedf-e2ec65a4153a@googlegroups.com
|