Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing only one line in a file

Status
Not open for further replies.

ridzz

Programmer
Sep 30, 2001
23
0
0
MY
Hello..
I've been wondering if i can change one line (or at most a few lines) from a file, without changing the rest of the lines in the file. Is it possible to carry this out using a batch file, and how to do that? Thanx in advance..
 
The question is not very clear to me, what sort of file? More information required. All things are possible except skiing through a revolving door.
 
Can you put up a little sample showing what is to be changed?

In general, no, Dos Batch and NT commands do not let you find lines in a file and change them leaving the rest alone.


If you had and area that was going to be changed you could flag the start of the area and the end and then write a very sinple program to change them, any BASIC, C/++, Delphi, ForTran or even COBOL (smile).

There also is the River which does that, but I cannot plug. Offline: j@roninsg.com

 
Thanx for the info.. Actually, the file that I wanted to change has a few lines that often changes. So, I want to be able to change those lines without the users having to open the file and change it for themselves. Part of the original file is like this..

--------
1 DEFINE_LOCAL_CP FQ_CP_NAME(PPNET89.XXXXXXXX )
2 DESCRIPTION(Created on 08-17-92 at 05:02p)
3 CP_ALIAS(MERSVR )
4 NAU_ADDRESS(INDEPENDENT_LU)
5 NODE_TYPE(EN)
6 NODE_ID(AAAAAAAA')
7 NW_FP_SUPPORT(NONE)
--------

XXXXXXXX and AAAAAAAA is the part where I want to make the change.

I used SED to find and replace the original sequence with a user input. However, since XXXXXXXX is always changing, I think I need to use wildcard characters to make the substitution. But so far, nothing happened. Maybe u guys could take a look at it.

This is what I wrote :
SED "/DEFINE_LOCAL_CP/s/(PPNET89.*)/PPNET89.%2%/g" FBSSCFG.ndf >> TEMP.TXT

What do u think?
 
Oppss nevermind.. I think I got it. My mistake. It works fine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top