how to read a file in reverse order using a b

Microsoft Windows xp professional w/sp2
May 5, 2010 at 08:26:34
Specs: Windows XP
how can read the contents of a file in reverse

See More: how to read a file in reverse order using a b

May 5, 2010 at 08:32:51
You start at the end and work your way to the beginning.

What type of file you are trying to read and what you are reading it with would be an enormousness help.


Report •

May 5, 2010 at 22:21:02
i'm trying to create a tab seperated file it should look like this
1 2 13
but it the file i created is 1
i want to read a text file using a batch program in reverse ....if you could tell me how to create a tab seperated file it would be great..

@echo off
echo Enter File Name
set TAB=
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="" goto input
echo Your input was: %INPUT%

FOR /L %%i IN (11 1 99) DO echo %%i >> %INPUT%
FOR /F "delims=TAB" %%i IN (%INPUT%) DO echo %%i >> %INPUT%
sort /R %INPUT% >>result.txt

Report •

May 5, 2010 at 23:13:05
yeah, you are kind of non-linear where the delims are concerned.
the delims is only for input, not output.
what you want, it think, is:
:of course, that's a real tab in foll, not []
set tab=[]
:first, generate the numbers. then sort the numbers to "result".
:then, reformat the numbers using tabs back out to "final"
for /L %%i in (11 1 99) do echo %%i >> %input%
sort /r %input% >> result.txt
for /f %%a in (result.txt) do set x=!x!!tab!%%a
> final echo !x!

Report •

Related Solutions

May 6, 2010 at 00:40:25
hey nbrane thanks for the reply...i really appreciate it

for /f %%a in (result.txt) do set x=!x!!tab!%%a
echo !x!
the result that i get is !x! i need to change anything???

Report •

May 6, 2010 at 01:59:08
Here's a pretty hideous batch solution to "read" a file in reverse, without a temp file.
The file is actually read multiple times. Because it uses "sort" I can't be 100% sure it would
always be accurate.

The file variable holds the file name.

@echo off
SetLocal EnableDelayedExpansion
set list=
set file="file"
if not exist %file% goto :eof

for /f %%a in (' find /c /v "" ^< %file% ') do (
    for /f %%b in (' cmd /u /c set /p "=%%a"^<nul^|find /v /c "" ') do set maxplaces=%%b

for /l %%a in (%maxplaces% -1 1) do (
    for /l %%b in (1 1 %%a) do (
        set list=!list![0-9]
    set list=!list!,

for /f "tokens=1* delims=]" %%y in ('
    cmd /C "for %%b in (%list%) do @type %file%|find /n /v ""|findstr /b \[%%b\]|sort /r "
') do echo line:%%y] - %%z

Report •

May 6, 2010 at 04:45:12
Hi Stuart,

Thanks, I needed a good laugh.

Helping others achieve escape felicity


Report •

Ask Question