How to change order of echo in output txt.file.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dan_sl
Posts: 3
Joined: 15 Oct 2012 03:58

How to change order of echo in output txt.file.

#1 Post by dan_sl » 15 Oct 2012 05:52

Hi to All.

How I can change the order echo output lines.

Example.

Exa.bat
echo 1 >> c:\test.txt
echo 2 >> c:\test.txt

output from first running at 10:00 AM
test.txt
1
2

output in second running 10:01 AM
test.txt
1 the value from first running
2 the value from first running
**************************
1 the value from second running
2 the value from second running


I want to output in different order the last running will showe up at the first Example:

output from first running at 10:00 AM
test.txt
1 the value from first running
2 the value from first running

Output in second running 10:01 AM

1 the value from second running
2 the value from second running
*************************

1 the value from first running
2 the value from first running


Thank you for advance.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to change order of echo in output txt.file.

#2 Post by foxidrive » 15 Oct 2012 06:03

This will add the new data to the top of "original-file.txt"

Code: Select all

@echo off
>>tmp.tmp echo 1
>>tmp.tmp echo 2
type "original-file.txt" >> "tmp.tmp"
move /y "tmp.tmp" "original-file.txt"

dan_sl
Posts: 3
Joined: 15 Oct 2012 03:58

Re: How to change order of echo in output txt.file.

#3 Post by dan_sl » 15 Oct 2012 06:28

foxidrive wrote:This will add the new data to the top of "original-file.txt"

Code: Select all

@echo off
>>tmp.tmp echo 1
>>tmp.tmp echo 2
type "original-file.txt" >> "tmp.tmp"
move /y "tmp.tmp" "original-file.txt"



Thank you very much its works perfectly what I need. :D

dan_sl
Posts: 3
Joined: 15 Oct 2012 03:58

Re: How to change order of echo in output txt.file.

#4 Post by dan_sl » 15 Oct 2012 07:31

Thanks

Post Reply