windows - 从 10GB Informatica 会话日志中读取前 10 行的 Windows 批处理脚本
问题描述
Windows 批处理控制台中的 for 循环在处理 10 GB 的大文件时挂起并且不起作用,但适用于小于 1 GB 的较小文件。例如
FOR /F "delims=]" %%A IN (dummy.txt) DO (
...code...
)
我需要一个批处理脚本,它可以有效地从 10 gb Informatica 会话日志文件中读取前 10 行代码。有没有办法使用批处理编程来读取大文件?
解决方案
尝试这个:
@echo off
setlocal EnableDelayedExpansion
rem Read first 10 lines
(for /L %%i in (1,1,10) do set /P "line[%%i]=") < dummy.txt
rem Process them
for /L %%i in (1,1,10) do (
echo Line %%i- !line[%%i]!
FOR /F "delims=]" %%A IN ("!line[%%i]!") DO (
...code...
)
)
PS - 我敢打赌这种方法比 PowerShell 运行得快得多!;)
推荐阅读
- java - ToString 方法 print String Objcet like Char 数组
- csv - 除非共享对所有人具有完全控制权,否则 SSRS OLEDB CSV 源将不起作用。Excel 可以在具有只读访问权限的共享上工作
- mdx - OLAP 多维数据集 - 上次读取/访问维度时
- gradle - 使用 KotlinDSL 在 Gradle 中创建 Fat Jar
- rest - .NET Core 下的单元测试 (xUnit) NLog 日志记录服务
- c# - C#循环遍历列表并提取特定数据
- python - 有没有办法隐藏或加密边缘设备的 python 代码?有什么方法可以防止对python代码进行逆向工程?
- c - 使用无效指针的动态数组进行错误重新分配
- azure - 是否可以在 App Insights 内联函数中获取查询结果?
- jax-rs - 带有计数正则表达式的 JAX-RS 路径