coreutils
[Top][All Lists]
Advanced

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

Re: tsort: "odd input of tokens" with paired input


From: Michael V. Antosha
Subject: Re: tsort: "odd input of tokens" with paired input
Date: Wed, 6 Apr 2016 13:45:31 +0300

Hello Alad,


On 4/6/16, Alad Wenter <address@hidden> wrote:
> Hello,
>
> When trying to run tsort on a moderately large
> paired list, I get:
>
> tsort: -: input contains an odd number of
> tokens

I think, 'tsort' needs improvement to make its
diagnostics more convenient for practical use
cases (input line number could help in this
case).


> However, both columns have the same amount of
> entries:
>
> awk '{print $1}' pre_tsort.txt | wc -l
> 637
>
> awk '{print $2}' pre_tsort.txt | wc -l
> 637

Your commands does not seem to support your
statement.


1) The commands will output 637 for any field
number of your file.  Try, this, for exmaple:

    awk '{print $9}' pre_tsort.txt | wc -l

Remove empty lines before passing data to 'wc' if
you want to count lines containing a non-empty
value in a field you test.


2) What if your file contains lines with more
than two fields?...  Particularly, you did not
checked this:

    awk '{print $3}' pre_tsort.txt | egrep -v '^$' | wc -l


3) You could also try idea of binary search to
find out exactly (in less than 15 simple steps
for the case of 637 lines) which line of your
file introduces the problem:

head -1 pre_tsort.txt | tsort  # success
head -637 pre_tsort.txt | tsort  # error
head -319 pre_tsort.txt | tsort  # error
head -160 pre_tsort.txt | tsort  # error
head -80 pre_tsort.txt | tsort  # success
head -120 pre_tsort.txt | tsort  # error
head -100 pre_tsort.txt | tsort  # error
head -90 pre_tsort.txt | tsort  # error
head -85 pre_tsort.txt | tsort  # success
head -87 pre_tsort.txt | tsort  # success
head -88 pre_tsort.txt | tsort  # success
head -89 pre_tsort.txt | tsort  # success
# First 89 lines are okay.  Line 90 is bad.


Best regards,
Michael.


-- 
Michael V. Antosha
http://mivael.in.ua
xmpp:address@hidden   (Jabber ID)



reply via email to

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