Reputation: 23
I want to get last line of this link (https://pastebin.com/raw/s5BxuEEw
) and +1 it and save as integer.
For example if the last line is 5 , put 6 in variable.
I can get content with this code but I dont know how to filter last line:
@echo off
for /f "tokens=*" %%i in ('powershell /command "(Invoke-WebRequest -Uri 'https://pastebin.com/raw/s5BxuEEw').Content"') do set return=%%i
echo "%return%"
pause
Upvotes: 2
Views: 140
Reputation:
To select only the last line from url content use index [-1]
(but the for /f would nevertheless iterate ALL lines and only the last persists)
To add / increment a number use set /A
@echo off
set "URI=https://pastebin.com/raw/s5BxuEEw"
for /f "tokens=*" %%i in ('
powershell -NoP -C "(Invoke-WebRequest -Uri '%URI%').Content[-1]"
') do set /A "return=%%i+1"
echo "%return%"
pause
Sample output is
"6"
Upvotes: 2