我已经生成了wordlist.txt11 GB 的crunch-3.6. 当我尝试使用 Vi 或 gedit 打开文件时,由于文件大小而遇到问题。如何查看此文件?
pLu*_*umo 48
不要使用文本编辑器进行查看的文本。
有更好的工具:
查看文件less(用空格滚动、结束、主页、PageUp、PageDown;用“/something”搜索;用 q 离开)。
从less手册:
Less 在开始之前不必读取整个输入文件,因此对于大输入文件,它比 vi (1) 等文本编辑器启动得更快。
用法:
less wordlist.txt
Run Code Online (Sandbox Code Playgroud)
考虑使用less -n:
-n 或 --line-numbers:
抑制行号。在某些情况下,默认值(使用行号)可能会导致 less 运行更慢,尤其是对于非常大的输入文件。使用该
-n选项抑制行号将避免此问题。
(感谢您建议 -n 选项@pipe)
用于grep仅获取您感兴趣的行:
# 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
Run Code Online (Sandbox Code Playgroud)
使用head或tail获取前 n 行或最后 n 行
head wordlist.txt
tail -n 200 wordlist.txt
Run Code Online (Sandbox Code Playgroud)
有关编辑文本,请参阅此问题。
小智 11
通常,只需“grep”就足以找到您需要的东西。
如果在特定行周围需要更多“上下文”,则使用“grep -n”查找感兴趣行的行号,然后使用 sed 打印出该行周围文件的“块” :
$ 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
Run Code Online (Sandbox Code Playgroud)