Script that Accurately counts lines in a text file
17 ビュー (過去 30 日間)
回答 (2 件)
Guillaume 2019 年 4 月 2 日
linecount = sum(fileread(somefile) == 10) + 1;
See Walter's comment. This will count the emptiness between the newline and end of file as a line if the last line ends in a newline.
Will works both for Windows and Linux line ending (but not old style macs which used char(13) solely as a newline marker).