change of a string in different lines

hello,
i have a dynamic file, which is generated by an ORACLE tool. Now i want to change a string, which begins with TABLESPACE following by "Name of Tablespace". The name of the new TABLESPACE is static.

Example: TABLESPACE new : APPLI
old: TABLESPACE "AMITTEL"
new: TABLESPACE "APPLI"

this is easy but i have following situation:

REM 255 TABLESPACE "AMITTEL" LOGGING PARTITION BY RANGE ("FIRMA" ,
REM "BON_DATZT" ) (PARTITION "FA_00_WO_0ANF" VALUES LESS THAN ('00',
REM 255 STORAGE(INITIAL 262144 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE
REM "APPLI" LOGGING NOCOMPRESS, PARTITION "FA_00_WO_200801" VALUES LESS

i attach the whole file.i don't know, how to change it over different lines ...

regards,tom

Please be more clear on what you're asking for. I looked at your file, and it doesn't contain the value AMMITAL anywhere. So it seems you've already replaced it successfully.

I must not be understanding what you're asking, or you've attached the wrong file.

I guess its a typo that you mention to replace AMITTEL as there is only APPLI in the sample file.

Please try the below code:

sed 's/APPLI/AMITTEL/g' filename >modified_file

or

perl -ne 's/APPLI/AMITTEL/g; print; ' filename

hello,

i want to change all entries of TABLESPACE "*":

i have a string, which occurs in one line like :
REM 255 TABLESPACE "AMITTEL" LOGGING PARTITION BY RANGE ("FIRMA" ,

then i also i have a string, which occurs in different lines like:
REM "BON_DATZT" ) (PARTITION "FA_00_WO_0ANF" VALUES LESS THAN ('00',
REM 255 STORAGE(INITIAL 262144 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE
REM "APPLI" LOGGING NOCOMPRESS, PARTITION "FA_00_WO_200801" VALUES L

i think , the first way is to change "REM " (with sed ) but then i want to
change all entries with TABLESPACE "*" through TABLESPACE "XX"

regards,tom

I got an solutions of experts:

# perl -00 -pe 's/TABLESPACE "AMITTEL"/TABLESPACE "APPLI"/gms;s/(TABLESPACE\s*REM\s*)"AMITTEL"/$1"APPLI"/gms' file

or

# perl -00 -pi.old -e 's/TABLESPACE "AMITTEL"/TABLESPACE "APPLI"/gms;s/(TABLESPACE\s*REM\s*)"AMITTEL"/$1"APPLI"/gms' file

or

# perl -0 -pe 's/TABLESPACE(\s+|\s*REM\s*)"\w+/TABLESPACE$1"appli/g' old.tmp > new.tmp