Thank you!
Here are two:
set /p "var="<"data.txt"
echo %var%
for /f "delims=" %%a in (data.txt) do set "var=%%a"&goto :stop
:stop
echo %var%
--
Regards,
Mic
and here's a third:
(set var=)
for /f "delims=" %%a in (data.txt) do if not defined var set var=%%a
"billious" <billio...@hotmail.com> wrote in message
news:d5CdnfQCicNPrkfQ...@westnet.com.au...
set var
@echo off & setlocal enableextensions
set myfile_=My test file.txt
for /f "tokens=1,* delims=:" %%a in (
'"findstr /n . "%myfile_%"|findstr /b 1:"') do (
set FirstLine=%%b)
echo FirstLine=%FirstLine%
endlocal & goto :EOF
23} How do I get the n'th, the first and the last line of a text file?
http://www.netikka.net/tsneti/info/tscmd023.htm
All the best, Timo
--
Prof. Timo Salmi mailto:t...@uwasa.fi ftp & http://garbo.uwasa.fi/
Hpage: http://www.uwasa.fi/laskentatoimi/english/personnel/salmitimo/
Department of Accounting and Finance, University of Vaasa, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.php
for /f "tokens=1* delims=*" %%a in ('
"(echo l&echo e)|edlin /b data.txt|find "1:*""
') do echo %%b
and..
cd.>µ
for /f "tokens=1*" %%a in (
'"fc /n /a data.txt µ|find "1:""'
) do echo %%b
del µ
All these are excellent and useful learning exercises about the
intricacies of cmd script programming. They are exactly what this
discussion newsgroup basically is about. I like this.
However, if the actual goal is effective solutions for "production
purposes", then our solutions are esoteric and too prone to several
catches like the poison characters. In the production line a sed or a
gawk or a VBS-aided solution is the effective and safe way to go.