I'm running curl through a batch file and print the output to a text file. I want to copy the last line of this text file to another file so i'll have something like:
The first file:
0 594M 0 1017k 0 0 813k 0 0:12:27 0:00:01 0:12:26 813k
0 594M 0 2735k 0 0 1215k 0 0:08:20 0:00:02 0:08:18 1215k
0 594M 0 5074k 0 0 1561k 0 0:06:29 0:00:03 0:06:26 1561k
1 594M 1 6716k 0 0 1580k 0 0:06:25 0:00:04 0:06:21 1580k
1 594M 1 8027k 0 0 1489k 0 0:06:48 0:00:05 0:06:43 1566k
1 594M 1 8438k 0 0 1350k 0 0:07:30 0:00:06 0:07:24 1484k
1 594M 1 8883k 0 0 1225k 0 0:08:16 0:00:07 0:08:09 1229k
1 594M 1 9555k 0 0 1158k 0 0:08:45 0:00:08 0:08:37 896k
The second file:
1 594M 1 9555k 0 0 1158k 0 0:08:45 0:00:08 0:08:37 896k
The batch file is:
curl -v -o NUL "http://...." 2>> file1.txt
timeout 10 /NOBREAK
copy /y file1.txt file1.tmp.txt 1>nul
setLocal EnableDelayedExpansion
for /f "tokens=* delims=" %%a in (file1.tmp.txt) do (
set var_file1=%%a
)
echo !var_file1!
echo !var_file1! > file2.txt
The problem is that the first echo line prints the last line but the second line copy the entire file1 to file2.
What should I change in order to copy only the last line of file1 to file2 ?
Thanks!
Aucun commentaire:
Enregistrer un commentaire