我需要从文件中打印每个单词的重复次数。 但我不明白如何阅读Win CMD和Bash中的文字。 我该怎么做?
使用terminal显示图像,而不会失去焦点
pipe道操作员是否修改其input/输出? 还是ls知道pipe道?
Bash:使用>运算符写入并追加到文件
仅Windows批处理
限制
8191 (Windows XP +)的批生产线长度限制。 2047为较旧的操作系统。
脚本
@echo off setlocal EnableExtensions disableDelayedExpansion for /f "delims=" %%A in (file.txt) do ( set "_=%%A" call :Expand_ ) :: display the Word and Count rem set word: for /f "tokens=2,3 delims=:=" %%X in ('set word:') do echo %%X = %%Y goto End :Expand_ :: Clean Special Characters set "_=%_:"=%" set "_=%_:^=%" set "_=%_:<=%" set "_=%_:>=%" set "_=%_:&=%" set "_=%_:|=%" :: Replace Whitespace set "_=%_: =%" :: Remove Plurals rem set "_=%_:'s=%" :: Clean Punctuation :WordLoop for /f "tokens=1,* delims=`~!@#$%%*()-_+=[]{};:/?.," %%X in ("%_%") do ( set ".=%%X" call :Expand. set "_=%%Y" ) if defined _ goto WordLoop goto :eof :Expand. :: Count the Words if defined word:%.% ( set /a "word:%.%+=1" ) else ( set "word:%.%=1" ) goto :eof :End endlocal
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。