批找到TSV或文本文件中的一串数字,把它变成一个变量 [英] batch to find a string of numbers from tsv or text file and put it into a variable

查看:452
本文介绍了批找到TSV或文本文件中的一串数字,把它变成一个变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我想用一个批处理文件来寻找数字在TSV文件的第三行一些文本sampletext 1345678后的字符串.tsv文件。我希望把数字填进一个变量然后打印该变量在一个临时文本文件。我试图寻找这样的事情,但没有比赛,我想做些什么。


解决方案

 设置VAR =
FOR / F跳过= 2tokens = 2%% i的(whatever.tsv)做,如果没有定义一套变种变种= %%我
回声发现%VAR%

要做到这一点(作为一个批处理文件片断)

I have a .tsv file that I would like to use a batch file to search for a string of numbers after some text "sampletext 1345678" at the 3rd line of the tsv file. I would like to put the numbers into a variable then print that variable in a temporary text file. I've tried searching for something like this but nothing matches what I would like to do.

解决方案

set "var="
for /f "skip=2tokens=2" %%i in (whatever.tsv) do if not defined var set var=%%i
echo found %var%

should accomplish this (as a batchfile snippet)

这篇关于批找到TSV或文本文件中的一串数字,把它变成一个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆