开发者

Read numbers after equals sign DOS Command Prompt

开发者 https://www.devze.com 2023-02-05 07:56 出处:网络
In Cmd.exe, how do I keep only the number after an equal sign in a text file? Input file (input.txt) looks like...

In Cmd.exe, how do I keep only the number after an equal sign in a text file?

Input file (input.txt) looks like...

Line1=1.234 开发者_StackOverflow社区

Line2=5.432

.

.

Line10=3.456

I want the outuput file (output.txt) to look like...

1.234

5.432

.

.

3.456

Thank you for your help.


This should do it:

FOR /F "delims== tokens=2" %%a IN (input.txt) DO @ECHO %%a >> output.txt


You would need to manipulate the input file in a Batch file. Here are some tips on string manipulation commands:

http://www.dostips.com/DtTipsStringManipulation.php


With sed:

sed "s/^line[0-9]\+=//g" input.txt > output.txt
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号