16

When you pass a text file to the Unix file command, it might tell you something like:

input.txt: UTF-8 Unicode English text, with very long lines

Can somebody tell me the minimum number of characters a line must contain to be considered very long? The man pages don't say anything about this and I don't want to search the source code. If someone can tell me how to put this question into a Google query which doesn't return a billion results, almost all of which are irrelevant, I'd be happy, too.

2
  • 3
    Vote to move to superuser due to the reluctance to search the source code. Jan 5, 2010 at 11:04
  • You guys have a point - I'll search the source code next time. Thanks, anyways!
    – ferdystschenko
    Jan 5, 2010 at 11:26

4 Answers 4

23

From ascmagic.c in the file source package on Ubuntu:

#include "names.h"

#define MAXLINELEN 300  /* longest sane line length */
#define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \
          || (x) == 0x85 || (x) == '\f')

Seems like a line needs to be more than 300 characters to be considered "very long".

7

Over 300 chacracters, according to lines 52 and 214-215 in ascmagic.c in the source code.

The source code can be found here (link fetched from the Debian man page for file): ftp://ftp.astron.com/pub/file/

7

Brute force (plus this is a program, right? so it makes it programming related?):

$ for i in {1..301}; do printf "%${i}s" "." | file - | grep very && echo $i; done
/dev/stdin: very short file (no magic)
1
/dev/stdin: ASCII text, with very long lines, with no line terminators
301
2

A line is considered long if it has more than 300 characters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy