Computing.Net > Forums > Programming > How to Append Text In a File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to Append Text In a File

Reply to Message Icon

Name: Samriti
Date: June 5, 2007 at 04:26:57 Pacific
OS: Win2000
CPU/Ram: 1GB
Product: HP
Comment:

Hi

Please help me out in this!

I'm making a batch file to automate the Trigger Settings.

There is a file ibmp.properties having a parameter "Clients.jar" containing all the jar files entries as its value(comma separated).

I want to add a new value to this parameter in addition to the old values.

I'm doing the following for this :

echo Client.Jars=ssacustom.jar >> %SERVERROOT%\bin\ibpm.properties

But this is creating a new parameter-value pair (Client.Jars=ssacustom.jar ) at the end of the file, rather then appending the value to the existing parameter.

Please help me in this. Tell me where I'm wrong and how can I rectify it.




Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: June 5, 2007 at 06:54:12 Pacific
Reply:

Hi
@echo off
rem Create XECHO.COM
echo N XECHO.COM >~x.txt
echo A 100 >>~x.txt
echo MOV AH,2 >>~x.txt
echo MOV SI,82 >>~x.txt
echo MOV,DL,[SI] >>~x.txt
echo CMP DL,D >>~x.txt
echo JZ 113 >>~x.txt
echo MOV AH,2 >>~x.txt
echo INT 21 >>~x.txt
echo INC SI >>~x.txt
echo JMP 105 >>~x.txt
echo MOV AH,4C >>~x.txt
echo INT 21 >>~x.txt
echo. >>~x.txt
echo R CX >>~x.txt
echo 17 >>~x.txt
echo W >>~x.txt
echo Q >>~x.txt
debug <~x.txt > nul
del ~x.txt
echo XECHO.com created

----------

Run this batch file to create XEcho.com.
Then will then echo a line without a Carriage Return plus LineFeed at the end of the line.
Use like this.

xecho 12345 > test.txt
xecho 6789 >> test.txt
test.txt now contains 123456789
The next echo command will append to the end 123456789 so to force a newline use echo. >> test.txt. Then use echo or xecho command as required.


0

Response Number 2
Name: ghostdog
Date: June 5, 2007 at 22:37:45 Pacific
Reply:

use an appropriate tool for the job. If you have GNUawk/perl/vbscript/etc...its easier...
in GNUawk
[code]
awk '/Client.Jars/{print $0",ssacustom.jar";next}{print}' "file"
[/code]


0

Response Number 3
Name: Samriti
Date: June 14, 2007 at 05:50:40 Pacific
Reply:

Thanks for your replies.

I used SED(stream editor) for this and it worked.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: How to Append Text In a File

how to calculate words in a file www.computing.net/answers/programming/how-to-calculate-words-in-a-file/17761.html

batch to change lines in a file www.computing.net/answers/programming/batch-to-change-lines-in-a-file/18174.html

Read and Write in Batch file www.computing.net/answers/programming/read-and-write-in-batch-file/16655.html