On Thu, Nov 13, 2008 at 10:20 PM, Bob Proulx <[EMAIL PROTECTED]> wrote:
>> So if I ask in debian-devel: "What is the recommended way to view a
>> file?", what will the answer be?
>
> However even if you do not like any of the recommendations it doesn't
> change the fact that 'cat' isn't designed as a binary file browser.
> Trying to make cat into a binary file browser isn't the right answer.

Note that I'm not looking for a binary file browser.
I'm trying to view files that are mostly text, like MySQL query logs.
Part of the query might be a short binary string, but that's quite
different from your typical executable binary.

> I observe that it is at these times, when the needs of the system does
> not fit the needs of the user, that people develop the tools which
> become the right tool for the job.  This might be the perfect time to
> *develop* a good tool for your problem.

> Also changing the behavior of core programs has a very high
> multiplier.  (Colloquially we might say it has high leverage or has
> high fanout.)  Even if the likelihood of breakage for something is low
> the risk from that breakage is very high.  A very small number
> multiplied by a very large number.  The result has a large and
> unpredictable risk.  Like a surgical procedure with small and
> questionable benefit.  Ninety nine out of a hundred patients have no
> side-effects.  But one out of a hundred patients die from it.  Would
> you have the procedure?

That's certainly a good point, yes.

> No single straw breaks the camel's back.  It is the sum accumulation
> of so very many small straws that overloads the camel.

Hmm, I'm not sure how that fits in.

>> And what is your recommendation? I don't want paging.
>
> Others have suggested 'cat -v' (I personally don't like it for the
> above reasons but, it has been around for a long time).  I thought the
> 'vis' and 'unvis' programs from 4.4BSD were the better choice.  They
> were invertible.  For portability I would probably use 'sed'.  (He
> says portability and then uses a POSIX character class... :-)
>
>  sed 's/[^[:print:]]/?/g'

Hmm, I think cat -v is a bit easier to remember. ;)

> Personally I use 'strings' for extracting printable strings from mixed
> text and binary files.

That's not really what I try to do.

>> What is the major usage of tail? To the terminal or not to the terminal?
>
> Certainly not to the terminal.  The 'tail' program is widely used in
> scripts.  Although it is also often used in a terminal I would think
> that pagers would be more common for that purpose.

Using the same applications / interfaces for both humans and scripts
seems to lead to this kind of problems indeed.

> Again, use of 'strings' here is probably what you want.
>
>  tail -f /var/log/mysql/mysql-bin.* | strings

That's not the query log...



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to