While writing a Perl script, I got a requirement to write the user names with comma separation in only one line of the file.
That's why I would like to know is there any restriction on the maximum size of the line in the .txt file.
While writing a Perl script, I got a requirement to write the user names with comma separation in only one line of the file.
That's why I would like to know is there any restriction on the maximum size of the line in the .txt file.
Text files are just like any other files and newline character is like any othe character, so only the usual filesize restrictions apply (4Gb size limit on older file systems, file must fit on the disk etc.)
You won't encounter any problem reading and writing it, unless you're reading it line by line—you can run out of memory then or encounter a buffer overflow of sorts. This may happen in any text editor or text processing program (such as sed or awk), because, unlike OS kernel, in those line separation matters
I would suggest keeping one user per line, as it's more natural to read and less error-prone when you process the file with an external program.
There is no size limit except your filesystem's which is most probably 2TB or something.
No, there is no such limit until you hit any file-size limits.
On some old Unix systems, some text utilities (e.g. join, sort and even some old awk) have a limit on the maximum line size. I think this is the limit of utilities but not the OS. GNU utilities do not have such a limit as far as I know and therefore Linux never has this problem.
file size depends on your OS's file system. Tools has no limit for such (or at-least I have never seen so far..)
The only thing you need to worry about is the size of the file that you can create and the size of the file that you can read.
Computers don't know anything about lines, which is an interpretation of the bytes in a file. We decide that there is some sequence of characters that demarcate the end of a line, and then tell our programs to grab stuff out of the file until it hits that sequence. To us, that's a line.
For instance, you can define a line in your text file to end with a comma:
$/ = ',';
while( <DATA> )
{
chomp;
print "Line is: $_\n";
}
__DATA__
a,b,c,d,e,f,g
Even though it looks like I have a single line under __DATA__
, it's only because we're used to books. Computers don't read books. Instead, this program thinks everything between commas is a line:
Line is: a
Line is: b
Line is: c
Line is: d
Line is: e
Line is: f
Line is: g