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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change record file

Status
Not open for further replies.

pirolgra

Technical User
Nov 11, 2002
25
IT
I want to change a record in a ascii file.
I have many files to change in many machine client aix.
Example :

record is:

MM_ALL_PERMITS FALSE

I must to change "FALSE" in "TRUE"
P.S. FALSE in not always in same position.
 
Hi Pirolgra

vi <file_name>

:%s/FALSE/TRUE/g

Then save and exit
:wq

You can use vi editor commands like that to have the work done.



sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
Hi Pirolgra

vi <file_name>
MM_ALL_PERMITS FALSE

:%s/FALSE/TRUE/g

Then save and exit
:wq

You can use vi editor commands like that to have the work done.



sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
It can be done non interactively by using sed utility...

Nothing is infeasible! in unix !!
So write a script by using sed with appropriate flags...
If u want my help in programming and automation ...Please give your specifications/all details...I will write a program and post at this forum...
As I am bz right now...I will write it after 7pm..after reaching home...
I can't spend much time on this forum now!


sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
hi ,
you can do something like this :-

#!/bin/ksh

INFILE=file__to_change
OUTFILE=file_with_changes

cat $INFILE | sed -e 's/FALSE/TRUE/' > $OUTFILE

exit 0

HTH
 
This is the contents of my file



MM_ALL_PERMITS FALSE
MM_BLOCK_L FALSE
MM_CARICA_DIRFIN TRUE
MM_CF_IP TRUE
MM_CITTA_LETT Bergamo
MM_CONTROLLI FALSE
MM_CTPY_RISK TRUE
MM_CV_BOLLI_MIN 2500
MM_CV_BOLLI_MAX 1800000
MM_C_DIRF_DEF TRUE
MM_DATA_VALUTA_REGOLARE TRUE
MM_DEP_VISTA TRUE
MM_DISPATCH TRUE
MM_D2_OUTR_PORT 611223
MM_D2_TD_PORT 611111
MM_D2_SPOT_PORT 611211
MM_EFF_PUT TRUE
MM_EXPORT 3
MM_FIXED_PERIOD_RULE 2
MM_F_SCOMPOSTO TRUE
MM_GIORNI_VALUTA 3-5-5-5-3-3-2-3
 
Hi Pir

I am back now as your answer does consume my 2 min of time..
It's okay...

It is simple one line ...if u want to put it in a script

#!/bin/ksh

sed -e 's/FALSE/TRUE/'</dir/file>/dir/file.out

Just
save and exit

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
ok ... but i must to change only record MM_ALL_PERMITS ( not all FALSE)

This is the contents of my file



MM_ALL_PERMITS TRUE
MM_BLOCK_L FALSE
MM_CARICA_DIRFIN TRUE
MM_CF_IP TRUE
MM_CITTA_LETT xxxxxxx
MM_CONTROLLI FALSE
MM_CTPY_RISK TRUE
MM_CV_BOLLI_MIN 2500
MM_CV_BOLLI_MAX 1800000
MM_C_DIRF_DEF TRUE
MM_DATA_VALUTA_REGOLARE TRUE
MM_DEP_VISTA TRUE
MM_DISPATCH TRUE
MM_D2_OUTR_PORT 611223
MM_D2_TD_PORT 611111
MM_D2_SPOT_PORT 611211
MM_EFF_PUT TRUE
MM_EXPORT 3
MM_FIXED_PERIOD_RULE 2
MM_F_SCOMPOSTO TRUE
MM_GIORNI_VALUTA 3-5-5-5-3-3-2-3

 
Hi pir

In your first post u mentioned that FALSE position will not be in the same location...right??? what are the prefixing words of false (record line) will it be same time every time?
u want to change only one FALSE of particular record...that
line num varies?clarify me...sp that I can give appropriate
answer.

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
yes,FALSE position will not be in the same location
I want to change only one FALSE of particular record
( for example MM_BLOCK_L FALSE)
The line number varies.

bye
 
Hi pir

Here we go! I got u now...


#!/bin/ksh

cd /dir
grep &quot;MM_BLOCK_L&quot; file|sed s/FALSE/TRUE/>file.out
sed -e /MM/d<file>>file.out

#end of the script


sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
Thank you sushveer.

The last command is : sed -e /MM_BLOCK_L/d<file>>file.out

is true???
 
yes..but it doesn't matter

sushveer
IBM certified specialist-p-series AIX5L System Administration
AIX/SOLARIS/WEBSPHERE-MQ/TIVOLI Administrator
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top