标题: [文本处理] 批处理命令findstr和find处理最大长度上限几例 [打印本页]
作者: ShowCode 时间: 2023-11-7 18:21 标题: 批处理命令findstr和find处理最大长度上限几例
测试环境
Win7: 6.1.7601
Win10: 10.0.19045.3570
Win11: 10.0.22621.2283- @echo off
- REM 生成单行超长的文本文件
-
- echo "en8190.txt"
- (for /l %%i in (1,1,8190) do (
- set /p =A<nul
- ))>"en8190.txt"
- echo,>>"en8190.txt"
-
- echo "en8191.txt"
- (for /l %%i in (1,1,8191) do (
- set /p =A<nul
- ))>"en8191.txt"
- echo,>>"en8191.txt"
-
- echo "en1000000.txt"
- (for /l %%i in (1,1,1000000) do (
- set /p =A<nul
- ))>"en1000000.txt"
- echo,>>"en1000000.txt"
-
- echo "cn4095.txt"
- (for /l %%i in (1,1,4095) do (
- set /p =中<nul
- ))>"cn4095.txt"
- echo,>>"cn4095.txt"
-
- echo "cn4096.txt"
- (for /l %%i in (1,1,4096) do (
- set /p =中<nul
- ))>"cn4096.txt"
- echo,>>"cn4096.txt"
-
- echo "cn1000000.txt"
- (for /l %%i in (1,1,1000000) do (
- set /p =中<nul
- ))>"cn1000000.txt"
- echo,>>"cn1000000.txt"
复制代码
作者: ShowCode 时间: 2023-11-7 18:22
以下测试假设文本行尾都带有回车换行。文本行尾不带回车换行的情况,得出的结果会略有差异。- REM findstr通过输入重定向输入获取数据,可以处理的单行最大长度为:
- REM 8190个英文或数字
- REM 4095个中文
- REM Win11系统上限未知
- findstr "A" < en8190.txt > en8190-s1.txt
- findstr "A" < en8191.txt > en8191-s1.txt
- findstr "中" < cn4095.txt > cn4095-s1.txt
- findstr "中" < cn4096.txt > cn4096-s1.txt
- REM 超出之后的报错信息为:FINDSTR: 行 1 太长。
-
-
- REM findstr通过管道获取数据,可以处理的单行最大长度为:
- REM 8190个单字节字符(英文或数字)
- REM 4095个双字节字符(中文)
- REM Win11系统上限未知
- type en8190.txt | findstr "A" > en8190-s2.txt
- type en8191.txt | findstr "A" > en8191-s2.txt
- type cn4095.txt | findstr "中" > cn4095-s2.txt
- type cn4096.txt | findstr "中" > cn4096-s2.txt
- REM 超出之后的报错信息为:FINDSTR: 行 1 太长。
-
- REM findstr直接从文件获取数据,尝试处理单行1000000的情况正常,不确定上限是多少
- findstr "A" en1000000.txt > en1000000-s0.txt
- findstr "中" cn1000000.txt > cn1000000-s0.txt
-
- REM find通过输入重定向输入获取数据,输出结果被截断至:
- REM 4095个单字节字符(英文或数字)
- REM 4095个双字节字符(中文)
- find "A" < en1000000.txt > en1000000-f1.txt
- find "中" < cn1000000.txt > cn1000000-f1.txt
-
- find "A" < en8190.txt > en8190-f1.txt
- find "中" < cn4096.txt > cn4096-f1.txt
-
- REM find通过管道获取数据,输出结果被截断至:
- REM 4095个单字节字符(英文或数字)
- REM 4095个双字节字符(中文)
- type en1000000.txt | find "A" > en1000000-f2.txt
- type cn1000000.txt | find "中" > cn1000000-f2.txt
-
- type en8190.txt | find "A" > en8190-f2.txt
- type cn4096.txt | find "中" > cn4096-f2.txt
-
- find "A" < en8190.txt > en8190-f1.txt
- find "中" < cn4096.txt > cn4096-f1.txt
-
- REM find直接从文件获取数据,输出结果被截断至:
- REM 4095个单字节字符(英文或数字)
- REM 4095个双字节字符(中文)
- find "A" en1000000.txt > en1000000-f0.txt
- find "中" cn1000000.txt > cn1000000-f0.txt
-
- find "A" en8190.txt > en8190-f0.txt
- find "中" cn4096.txt > cn4096-f0.txt
-
- REM findstr单个待查找关键字的最大长度为:
- REM 255个单字节字符(英文或数字)
- REM 127个双字节字符(中文)
- findstr "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" en8191.txt > en8191-s-p1.txt
- findstr "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" en8191.txt > en8191-s-p2.txt
- findstr "中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中" cn4095.txt > cn4095-s-p1.txt
- findstr "中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中" cn4095.txt > cn4095-s-p2.txt
- REM 超出之后的报错信息为:FINDSTR: 内存不足
-
- REM find单个待查找关键字的最大长度为:未知
- REM 只要整个命令不超过单行命令最大值8190即可
复制代码
作者: Five66 时间: 2023-11-7 23:11
win11这么强的???
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |