I have generated a wordlist.txt of 11 GB by crunch-3.6. When I try to open the file with Vi or gedit, I run into problems because of the file size. How can I view this file?
- 257
- 273
2 Answers
Don't use a text editor for viewing text.
There are better tools:
View files with less (Scroll with Space, End, Home, PageUp, PageDown; Search with "/something" ; Leave with q).
From less manual:
Less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi (1).
Usage:
less wordlist.txt
Consider the use of less -n:
-n or --line-numbers:
Suppresses line numbers. The default (to use line numbers) may cause less to run more slowly in some cases, especially with a very large input file. Suppressing line numbers with the
-noption will avoid this problem.
(thanks for suggesting -n option @pipe)
Use grep to get only the lines you're interested in:
# Show all Lines beginning with A:
grep "^A:" wordlist.txt
# Show all Lines ending with x and use less for better viewing
grep "x$" wordlist.txt | less
Use head or tail to get the first or last n lines
head wordlist.txt
tail -n 200 wordlist.txt
For editing text, refer to this question.
- 27,991
Often, just "grep" is enough to find what you need.
If you need more "context" around a particular line, then use "grep -n" to find the line numbers of the lines of interest, then use sed to print out a "chunk" of the file around that line:
$ grep -n 'word' file
123:A line with with word in it
$ sed -n '120,125p' file
A line
Another line
The line before
A line with with word in it
The line after
Something else
- 211