Read and change last symbols in text file
Posted: 10 Feb 2017 10:00
Hi guys, I'm trying to change some characters in txt file, but It's too difficult for my mind
I have a text file with some data and I need to replace last hex numbers in each string - result should be = 0x5b - 0x02 (for first string respectively)
so I try to do like this
but it doesn't work - set hex=0x%%g, where %%g last nubers in string.
Pls help me to fix my mistake.
Thank you.
I have a text file with some data and I need to replace last hex numbers in each string - result should be = 0x5b - 0x02 (for first string respectively)
Code: Select all
10.36.215.1 01 01 02 e0 36 76 d6 9f 5b
10.36.215.2 01 01 02 e0 36 76 d6 a2 4d
10.36.215.3 01 01 02 e0 36 76 d6 a5 99
10.36.215.4 01 01 02 e0 36 76 d6 a6 13
10.36.215.5 01 01 02 e0 36 76 d6 9c cd
10.36.215.6 01 01 02 e0 36 76 d6 a5 ff
10.36.215.7 01 01 02 e0 36 76 d6 a4 7f
10.36.215.8 01 01 02 e0 36 76 d6 a2 17
10.36.215.9 01 01 02 e0 36 76 d6 a3 7f
10.36.215.10 01 01 02 e0 36 76 d6 a2 61
10.36.215.11 01 01 02 e0 36 76 d6 a2 83
10.36.215.12 01 01 02 e0 36 76 d6 a4 a3
10.36.215.13 01 01 02 e0 36 76 d6 a1 e7
10.36.215.14 01 01 02 e0 36 76 d6 a3 fd
so I try to do like this
Code: Select all
FOR /F "tokens=1,5-10" %%a IN (tmp1.txt) do (
@echo %%a wrong WWN: 1000%%b%%c%%d%%e%%f%%g
@echo %WRITE2SW1%>>runme.txt
set hex=0x%%g
set /a varh=hex - 0x2
call :dec2hex %varh% results
@echo %%a correct WWN: 1000%%b%%c%%d%%e%%f%results%
)
but it doesn't work - set hex=0x%%g, where %%g last nubers in string.
Pls help me to fix my mistake.
Thank you.