Skip to main content
Commonmark migration
Source Link

Windows Batch Files - Version #2###2

@echo off
echo hello > fileio.txt
echo world  >> fileio.txt
set /P answer=Insert: 
echo %answer%  >> fileio.txt
for /f "skip=1 tokens=*" %%A in (fileio.txt) do echo %%A

To explain that last horrible looking for loop, it assumes that there is only hello (newline) world in the file. So it just skips the first line and echos only the second.

Changelog

  • #2 - Opps, must of misread the requirements or they changed on me. Now reads last line from file

    2 - Opps, must of misread the requirements or they changed on me. Now reads last line from file

Windows Batch Files - Version #2##

@echo off
echo hello > fileio.txt
echo world  >> fileio.txt
set /P answer=Insert: 
echo %answer%  >> fileio.txt
for /f "skip=1 tokens=*" %%A in (fileio.txt) do echo %%A

To explain that last horrible looking for loop, it assumes that there is only hello (newline) world in the file. So it just skips the first line and echos only the second.

Changelog

  • #2 - Opps, must of misread the requirements or they changed on me. Now reads last line from file

Windows Batch Files - Version #2

@echo off
echo hello > fileio.txt
echo world  >> fileio.txt
set /P answer=Insert: 
echo %answer%  >> fileio.txt
for /f "skip=1 tokens=*" %%A in (fileio.txt) do echo %%A

To explain that last horrible looking for loop, it assumes that there is only hello (newline) world in the file. So it just skips the first line and echos only the second.

Changelog

  • 2 - Opps, must of misread the requirements or they changed on me. Now reads last line from file

Opps, must of misread the requirements or they changed on me. Now reads last line from file
Source Link
TheLQ
  • 15k
  • 15
  • 74
  • 107

Windows Batch Files - Version #2##

@echo off
echo hello > fileio.txt
echo world  >> fileio.txt
set /P answer=Insert: 
echo %answer%  >> fileio.txt
for /f "skip=1 tokens=*" %%A in (fileio.txt) do echo %answer%%%A

StrangeTo explain that I couldn't getlast horrible looking for loop, it assumes that there is only hello echo %answer% > fileio.txt 2>&1 to output to stdout as well as(newline) world in the file. So it just skips the first line and echos only the second.

Changelog

  • #2 - Opps, must of misread the requirements or they changed on me. Now reads last line from file

Windows Batch Files

@echo off
echo hello > fileio.txt
echo world  >> fileio.txt
set /P answer=Insert: 
echo %answer%  >> fileio.txt
echo %answer%

Strange that I couldn't get echo %answer% > fileio.txt 2>&1 to output to stdout as well as the file

Windows Batch Files - Version #2##

@echo off
echo hello > fileio.txt
echo world  >> fileio.txt
set /P answer=Insert: 
echo %answer%  >> fileio.txt
for /f "skip=1 tokens=*" %%A in (fileio.txt) do echo %%A

To explain that last horrible looking for loop, it assumes that there is only hello (newline) world in the file. So it just skips the first line and echos only the second.

Changelog

  • #2 - Opps, must of misread the requirements or they changed on me. Now reads last line from file
Removed 'XP' - batch files are not restricted to XP
Source Link
user353297
  • 736
  • 2
  • 7
  • 13

Windows XP Batch Files

@echo off
echo hello > fileio.txt
echo world  >> fileio.txt
set /P answer=Insert: 
echo %answer%  >> fileio.txt
echo %answer%

Strange that I couldn't get echo %answer% > fileio.txt 2>&1 to output to stdout as well as the file

Windows XP Batch

@echo off
echo hello > fileio.txt
echo world  >> fileio.txt
set /P answer=Insert: 
echo %answer%  >> fileio.txt
echo %answer%

Strange that I couldn't get echo %answer% > fileio.txt 2>&1 to output to stdout as well as the file

Windows Batch Files

@echo off
echo hello > fileio.txt
echo world  >> fileio.txt
set /P answer=Insert: 
echo %answer%  >> fileio.txt
echo %answer%

Strange that I couldn't get echo %answer% > fileio.txt 2>&1 to output to stdout as well as the file

Post Made Community Wiki
Source Link
TheLQ
  • 15k
  • 15
  • 74
  • 107
Loading