最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Mac中统计某个目录下所有文件中的字符个数

Mac crifan 822浏览 0评论

对于此处:
想要统计,计算,所有目录,加起来的,里面的md,即markdown文件的总的字符个数。
mac summary total text file characters

count – Find the number of characters in a file using Python – Stack Overflow

wc — count of newlines, words, bytes, and characters
wc recursive folder

recursive wc on a directory?

bash – How to count all the lines of code in a directory recursively? – Stack Overflow

linux – Use wc on all subdirectories to count the sum of lines – Stack Overflow

linux – Total number of lines in a directory – Stack Overflow
mac total number of  text characters of  folder

macos – Search through text files in Mac OS X – Super User

How to Count the Number of lines, Words, and, Characters in a Text File from Terminal? – Python and R Tips
目前试了试
➜  android_app_security_crack git:(master) cd src
➜  src git:(master) ll
total 24
-rw-r--r--   1 crifan  staff   2.3K  7 16 21:08 README.md
-rw-r--r--   1 crifan  staff   6.7K  5  2  2019 SUMMARY.md
drwxr-xr-x   7 crifan  staff   224B  4 28  2019 android_background
drwxr-xr-x   6 crifan  staff   192B  4 24  2019 android_crack_tech
drwxr-xr-x  10 crifan  staff   320B  4 24  2019 android_crack_tool
drwxr-xr-x   6 crifan  staff   192B  4 29  2019 android_safety_tech
drwxr-xr-x   4 crifan  staff   128B  4 10  2019 appendix
drwxr-xr-x   5 crifan  staff   160B  4 10  2019 assets
drwxr-xr-x   3 crifan  staff    96B  4 10  2019 intro
➜  src git:(master) cloc .
92 text files.
92 unique files.
0 files ignored.
github.com/AlDanial/cloc v 1.76  T=1.10 s (83.5 files/s, 3537.8 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Markdown                        92            604              0           3295
-------------------------------------------------------------------------------
SUM:                            92            604              0           3295
-------------------------------------------------------------------------------
cloc是统计行数,不是字符个数。
➜  src git:(master) wc -c
^C
直接wc -c卡死了。
➜  src git:(master) wc -c ./*
2383 ./README.md
6885 ./SUMMARY.md
wc: ./android_background: read: Is a directory
wc: ./android_crack_tech: read: Is a directory
wc: ./android_crack_tool: read: Is a directory
wc: ./android_safety_tech: read: Is a directory
wc: ./appendix: read: Is a directory
wc: ./assets: read: Is a directory
wc: ./intro: read: Is a directory
9268 total
不对。
➜  src git:(master) find . -type f -print0 | wc -l --files0-from=-
wc: illegal option -- -
usage: wc [-clmw] [file ...]
参数不对。
➜  src git:(master) find . -type f -exec cat {} + | wc -l
102928
➜  src git:(master) find . -type f -exec cat {} + | wc -c
30604953
看起来像是,但是不确定是否真的是对的:
  • 总行数:102928 ?
    • 10万行?
  • 总字符个数:30604953 ?
    • 3000多万?个字符
➜  src git:(master) find . -type f -exec wc -l {} \; | awk '{total += $1} END {print total}'
102928
➜  src git:(master) find . -type f -exec wc -c {} \; | awk '{total += $1} END {print total}'
30604953
还是这个数。
➜  src git:(master) find . -name '*.md' | xargs wc -c
18736 ./appendix/reference.md
43 ./appendix/README.md
331 ./intro/README.md
6885 ./SUMMARY.md
2383 ./README.md
863 ./android_safety_tech/encrypt_overview/code_obfuscation.md
1719 ./android_safety_tech/encrypt_overview/README.md
11029 ./android_safety_tech/encrypt_overview/harden_method/common_harden_method.md
140 ./android_safety_tech/encrypt_overview/harden_method/common_harden_compare.md
369 ./android_safety_tech/encrypt_overview/harden_method/README.md
21 ./android_safety_tech/README.md
3418 ./android_safety_tech/encrypt_history.md
905 ./android_safety_tech/why_encrypt_harden.md
1761 ./android_crack_tech/how_apk_to_java_src/1_step_apk_to_java.md
143 ./android_crack_tech/how_apk_to_java_src/README.md
13072 ./android_crack_tech/how_apk_to_java_src/3_steps/2_dex_to_jar.md
1106 ./android_crack_tech/how_apk_to_java_src/3_steps/README.md
4759 ./android_crack_tech/how_apk_to_java_src/3_steps/3_jar_to_java.md
5177 ./android_crack_tech/how_apk_to_java_src/3_steps/1_app_dump_dex.md
1786 ./android_crack_tech/how_apk_to_java_src/crack_apk_intro.md
6002 ./android_crack_tech/how_remove_shell_unpacking.md
874 ./android_crack_tech/README.md
1852 ./android_crack_tech/how_deobfuscation.md
185 ./android_crack_tool/other_assistant_tool/binary_editor/README.md
430 ./android_crack_tool/other_assistant_tool/binary_editor/010editor.md
1827 ./android_crack_tool/other_assistant_tool/binary_editor/everedit.md
202 ./android_crack_tool/other_assistant_tool/fino.md
24 ./android_crack_tool/other_assistant_tool/README.md
450 ./android_crack_tool/other_assistant_tool/introspy_android.md
710 ./android_crack_tool/other_assistant_tool/redexer.md
937 ./android_crack_tool/other_assistant_tool/smaliviewer.md
885 ./android_crack_tool/other_assistant_tool/apk_analyzer.md
734 ./android_crack_tool/other_assistant_tool/classshark.md
164 ./android_crack_tool/other_assistant_tool/android_debugger/README.md
668 ./android_crack_tool/other_assistant_tool/android_debugger/android_opendebug.md
316 ./android_crack_tool/other_assistant_tool/android_debugger/andbug.md
2555 ./android_crack_tool/other_related_tool/file_browser.md
595 ./android_crack_tool/other_related_tool/android_hook_framework/cydia_substrate.md
473 ./android_crack_tool/other_related_tool/android_hook_framework/xposed_framework.md
2025 ./android_crack_tool/other_related_tool/android_hook_framework/frida.md
135 ./android_crack_tool/other_related_tool/android_hook_framework/README.md
113 ./android_crack_tool/other_related_tool/README.md
18 ./android_crack_tool/other_related_tool/android_emulator/README.md
416 ./android_crack_tool/other_related_tool/android_emulator/nox.md
27 ./android_crack_tool/README.md
402 ./android_crack_tool/other_crack_tool/smali_baksmali.md
587 ./android_crack_tool/other_crack_tool/ida.md
1056 ./android_crack_tool/other_crack_tool/radare2.md
7814 ./android_crack_tool/other_crack_tool/apktool.md
24 ./android_crack_tool/other_crack_tool/README.md
76 ./android_crack_tool/other_crack_tool/xml_crack/README.md
648 ./android_crack_tool/other_crack_tool/xml_crack/axmlprinter2.md
34 ./android_crack_tool/decompiler/common_decompilers/cfr.md
1572 ./android_crack_tool/decompiler/common_decompilers/jd_gui.md
337 ./android_crack_tool/decompiler/common_decompilers/dare.md
70 ./android_crack_tool/decompiler/common_decompilers/README.md
822 ./android_crack_tool/decompiler/common_decompilers/fernflower.md
5342 ./android_crack_tool/decompiler/common_decompilers/procyon/README.md
1839 ./android_crack_tool/decompiler/common_decompilers/procyon/luyten.md
465 ./android_crack_tool/decompiler/common_decompilers/krakatau.md
7128 ./android_crack_tool/decompiler/common_decompilers/jadx.md
474 ./android_crack_tool/decompiler/common_decompilers/jad.md
1216 ./android_crack_tool/decompiler/common_decompilers/gda.md
6387 ./android_crack_tool/decompiler/README.md
15355 ./android_crack_tool/decompiler/common_decompiler_compare.md
1116 ./android_crack_tool/other_integrated_tool/android_decompiler.md
1313 ./android_crack_tool/other_integrated_tool/dayanzai_android_hack.md
673 ./android_crack_tool/other_integrated_tool/crack_tool_mac.md
1042 ./android_crack_tool/other_integrated_tool/dayanzai_android_killer.md
214 ./android_crack_tool/other_integrated_tool/README.md
2123 ./android_crack_tool/other_integrated_tool/bytecode_viewer.md
361 ./android_crack_tool/other_integrated_tool/decompile_apk.md
1270 ./android_crack_tool/other_integrated_tool/androguard.md
514 ./android_crack_tool/other_integrated_tool/appknox_afe.md
618 ./android_crack_tool/app_to_dex/dumpdex.md
375 ./android_crack_tool/app_to_dex/fdex2.md
942 ./android_crack_tool/app_to_dex/drizzledumper.md
746 ./android_crack_tool/app_to_dex/dexextractor.md
687 ./android_crack_tool/app_to_dex/README.md
628 ./android_crack_tool/app_to_dex/indroid.md
661 ./android_crack_tool/dex_to_jar/dedexer.md
1341 ./android_crack_tool/dex_to_jar/enjarify.md
77 ./android_crack_tool/dex_to_jar/README.md
1756 ./android_crack_tool/dex_to_jar/dex2jar.md
286 ./android_background/related_info/smali_file.md
15 ./android_background/related_info/README.md
717 ./android_background/related_info/dex_file.md
922 ./android_background/related_info/apk_file.md
1351 ./android_background/apk_compile_process.md
822 ./android_background/android_framework.md
119 ./android_background/README.md
1642 ./android_background/crack_apk_process.md
171242 total
17万字符?倒是很像。
对于:
./appendix/reference.md 18736
去看了看:
1万8个字符?
4853个字符 ?
➜  src git:(master) find . -name '*.md' | xargs wc -m
14881 ./appendix/reference.md
17 ./appendix/README.md
135 ./intro/README.md
6405 ./SUMMARY.md
1365 ./README.md
415 ./android_safety_tech/encrypt_overview/code_obfuscation.md
845 ./android_safety_tech/encrypt_overview/README.md
5308 ./android_safety_tech/encrypt_overview/harden_method/common_harden_method.md
100 ./android_safety_tech/encrypt_overview/harden_method/common_harden_compare.md
169 ./android_safety_tech/encrypt_overview/harden_method/README.md
9 ./android_safety_tech/README.md
1576 ./android_safety_tech/encrypt_history.md
401 ./android_safety_tech/why_encrypt_harden.md
1201 ./android_crack_tech/how_apk_to_java_src/1_step_apk_to_java.md
63 ./android_crack_tech/how_apk_to_java_src/README.md
12112 ./android_crack_tech/how_apk_to_java_src/3_steps/2_dex_to_jar.md
584 ./android_crack_tech/how_apk_to_java_src/3_steps/README.md
3566 ./android_crack_tech/how_apk_to_java_src/3_steps/3_jar_to_java.md
3671 ./android_crack_tech/how_apk_to_java_src/3_steps/1_app_dump_dex.md
1154 ./android_crack_tech/how_apk_to_java_src/crack_apk_intro.md
4060 ./android_crack_tech/how_remove_shell_unpacking.md
524 ./android_crack_tech/README.md
1308 ./android_crack_tech/how_deobfuscation.md
69 ./android_crack_tool/other_assistant_tool/binary_editor/README.md
354 ./android_crack_tool/other_assistant_tool/binary_editor/010editor.md
895 ./android_crack_tool/other_assistant_tool/binary_editor/everedit.md
180 ./android_crack_tool/other_assistant_tool/fino.md
10 ./android_crack_tool/other_assistant_tool/README.md
356 ./android_crack_tool/other_assistant_tool/introspy_android.md
562 ./android_crack_tool/other_assistant_tool/redexer.md
583 ./android_crack_tool/other_assistant_tool/smaliviewer.md
615 ./android_crack_tool/other_assistant_tool/apk_analyzer.md
614 ./android_crack_tool/other_assistant_tool/classshark.md
62 ./android_crack_tool/other_assistant_tool/android_debugger/README.md
552 ./android_crack_tool/other_assistant_tool/android_debugger/android_opendebug.md
238 ./android_crack_tool/other_assistant_tool/android_debugger/andbug.md
1275 ./android_crack_tool/other_related_tool/file_browser.md
411 ./android_crack_tool/other_related_tool/android_hook_framework/cydia_substrate.md
305 ./android_crack_tool/other_related_tool/android_hook_framework/xposed_framework.md
1701 ./android_crack_tool/other_related_tool/android_hook_framework/frida.md
53 ./android_crack_tool/other_related_tool/android_hook_framework/README.md
41 ./android_crack_tool/other_related_tool/README.md
8 ./android_crack_tool/other_related_tool/android_emulator/README.md
214 ./android_crack_tool/other_related_tool/android_emulator/nox.md
11 ./android_crack_tool/README.md
390 ./android_crack_tool/other_crack_tool/smali_baksmali.md
471 ./android_crack_tool/other_crack_tool/ida.md
649 ./android_crack_tool/other_crack_tool/radare2.md
6868 ./android_crack_tool/other_crack_tool/apktool.md
10 ./android_crack_tool/other_crack_tool/README.md
32 ./android_crack_tool/other_crack_tool/xml_crack/README.md
552 ./android_crack_tool/other_crack_tool/xml_crack/axmlprinter2.md
34 ./android_crack_tool/decompiler/common_decompilers/cfr.md
1241 ./android_crack_tool/decompiler/common_decompilers/jd_gui.md
293 ./android_crack_tool/decompiler/common_decompilers/dare.md
26 ./android_crack_tool/decompiler/common_decompilers/README.md
759 ./android_crack_tool/decompiler/common_decompilers/fernflower.md
4904 ./android_crack_tool/decompiler/common_decompilers/procyon/README.md
1523 ./android_crack_tool/decompiler/common_decompilers/procyon/luyten.md
305 ./android_crack_tool/decompiler/common_decompilers/krakatau.md
5784 ./android_crack_tool/decompiler/common_decompilers/jadx.md
380 ./android_crack_tool/decompiler/common_decompilers/jad.md
766 ./android_crack_tool/decompiler/common_decompilers/gda.md
5009 ./android_crack_tool/decompiler/README.md
12997 ./android_crack_tool/decompiler/common_decompiler_compare.md
1042 ./android_crack_tool/other_integrated_tool/android_decompiler.md
849 ./android_crack_tool/other_integrated_tool/dayanzai_android_hack.md
528 ./android_crack_tool/other_integrated_tool/crack_tool_mac.md
638 ./android_crack_tool/other_integrated_tool/dayanzai_android_killer.md
92 ./android_crack_tool/other_integrated_tool/README.md
1383 ./android_crack_tool/other_integrated_tool/bytecode_viewer.md
297 ./android_crack_tool/other_integrated_tool/decompile_apk.md
916 ./android_crack_tool/other_integrated_tool/androguard.md
444 ./android_crack_tool/other_integrated_tool/appknox_afe.md
391 ./android_crack_tool/app_to_dex/dumpdex.md
285 ./android_crack_tool/app_to_dex/fdex2.md
610 ./android_crack_tool/app_to_dex/drizzledumper.md
482 ./android_crack_tool/app_to_dex/dexextractor.md
403 ./android_crack_tool/app_to_dex/README.md
346 ./android_crack_tool/app_to_dex/indroid.md
587 ./android_crack_tool/dex_to_jar/dedexer.md
914 ./android_crack_tool/dex_to_jar/enjarify.md
39 ./android_crack_tool/dex_to_jar/README.md
1418 ./android_crack_tool/dex_to_jar/dex2jar.md
132 ./android_background/related_info/smali_file.md
7 ./android_background/related_info/README.md
507 ./android_background/related_info/dex_file.md
510 ./android_background/related_info/apk_file.md
739 ./android_background/apk_compile_process.md
384 ./android_background/android_framework.md
43 ./android_background/README.md
832 ./android_background/crack_apk_process.md
126789 total
12万个字符?
感觉比较像。
14881 ./appendix/reference.md
1.4万个字符
13928个非空字符
和上面的 14881 很像。
后来去看了看,感觉是:把空格,换行等内容,也算进去了。
【总结】
目前,暂时用:
find . -name '*.md' | xargs wc -m
可以统计出,每一个md的Markdown文件的字符character个数,并且给出总数。
关于wc的用法,详见:

wc — count of newlines, words, bytes, and characters

转载请注明:在路上 » 【已解决】Mac中统计某个目录下所有文件中的字符个数

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
89 queries in 0.174 seconds, using 22.15MB memory