bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

possible bug--please help!!!


From: day
Subject: possible bug--please help!!!
Date: Wed, 13 Jan 2010 11:56:40 -0800
User-agent: Internet Messaging Program (IMP) H3 (4.1.6)

Hello! I have never submitted a bug before so please let me know if you need more details from me.

Background: I am calling gawk from a script (#!/bin/gawk). My input file, as viewed from VIM, is 439 lines long. On each line are uppercase letters with no spaces.
Example Input: ABCERFDHDSAEGJKL

My desired output is a newly created line that is alphabetized and unique.
Example Output: ABCDEFGHJKLRS

In order to do this, I read input into an array, like this.

gawk 'BEGIN {FS = "" ; RS = "\n"};
{
    for(x=1;x<=NF;x++)
    {
        array[x]=$x
    };
    asort(array);
    for(y=1;y<=NF;y++)
    {
        printf"%c",array[y]
    };
    printf"\n"
}

For the most part, this works, except for the first time there is some sort of repetition. Occasionally, my output becomes ABCDEFGHJKLRP. The last letter is swapped! This renders my awk program completely useless. Is this a bug or am I screwing something up here?

Thank you so much for your time!

Best,

Natt




reply via email to

[Prev in Thread] Current Thread [Next in Thread]