I have a file contains many lines, like 1 million lines, and
cat the_file
takes too much time to scroll.$ time cat 1m ...... cat 1m 0.00s user 11.21s system 28% cpu 38.839 total
How to make it faster? Like xterm or urxvt’s jumpScroll option?
I’m using PuTTY 0.62 and Windows 8 CP, If Windows 7 is necessary, I can change.
Here is the code I used to generate the file:
#include <stdio.h> int main(void) { int i; for (i = 2; i < 999999; i++) { printf("%d\n", i); } return 0; }
Answer
You can’t. This is why we shouldn’t log to stdout from our inner loops.
Meaningful logging can be implemented with modulus operations, but I get from your comments that you are asking if you can speed up putty.
Printing to stdout is viewing the file, in essence. Writing ‘blind’ to a file will be much faster, but this time lag you experience is pretty constant.
Attribution
Source : Link , Question Author : Mengdi Gao , Answer Author : serotonin