1834498 Members
2939 Online
110067 Solutions
New Discussion

Re: File Truncate

 
augusto cossa
Frequent Advisor

File Truncate

Good Day,

I have a file that has in the midle STORAGE WHAT_EVER....; and I would like to know if you know any script that can be run to truncate the file from where says STORAGE but do not delete (;).

Thanks,
A Cossa
6 REPLIES 6
Thomas G. Tudrej
Frequent Advisor

Re: File Truncate

Hi,

Please describe this problem better. Are you talking about file contents or file name, is file being held open by some process?

Regards,
TT
augusto cossa
Frequent Advisor

Re: File Truncate

Hi,

The text below is on vi editor. What I want is to delete on the text where found STORAGE until before any (;)

CREATE TABLE "ENV"."TE01_MESSAGE" ("CE01_MESSAGE_DATE" DATE NOT NULL
ENABLE, "CE01_FUNCTION_NAME" VARCHAR2(25) NOT NULL ENABLE,
"CE01_TYPE" VARCHAR2(1) NOT NULL ENABLE, "CE01_MESSAGE" VARCHAR2(200)
NOT NULL ENABLE, "CE01_MODULE_NAME" VARCHAR2(36),
"CE01_PACKAGE_ERROR_NUMBER" VARCHAR2(36), "CE01_ORACLE_USER"
VARCHAR2(10)) PCTFREE 5 PCTUSED 60 INITRANS 5 MAXTRANS 255 LOGGING
STORAGE(INITIAL 3727360 NEXT 745472 MINEXTENTS 1 MAXEXTENTS 5
PCTINCREASE 5 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "ENV_DATA2" ;
CREATE TABLE "ENV"."TE07_APPLICATION" ("CE07_USER_ID" VARCHAR2(15)
NOT NULL ENABLE, "CE07_APPL_NAME" VARCHAR2(25) NOT NULL ENABLE,
"CE07_APPL_PROGRAM" VARCHAR2(9) NOT NULL ENABLE, "CE07_DATABASE"
VARCHAR2(5) NOT NULL ENABLE, "CE07_UID" VARCHAR2(15) NOT NULL ENABLE,
"CE07_DMOD" DATE NOT NULL ENABLE) PCTFREE 5 PCTUSED 60 INITRANS 5
MAXTRANS 255 LOGGING STORAGE(INITIAL 32768 NEXT 8192 MINEXTENTS 1
MAXEXTENTS 5 PCTINCREASE 5 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL
DEFAULT) TABLESPACE "ENV_DATA2" ;
Paul Hite
Trusted Contributor

Re: File Truncate

Well, no money-back guarantee on this one, but try:

#! /usr/bin/ksh
sed 's/STORAGE[^;]*;/;/' | sed -n '/STORAGE/{
s/STORAGE.*//
p
: loop
n
s/[^;]*;/;/
t done
b loop
: done
p
b
}
p
'
exit 0
John Palmer
Honored Contributor

Re: File Truncate

Or simply in vi try:-
:%s/STORAGE.*;/;/
augusto cossa
Frequent Advisor

Re: File Truncate

Thanks Paul, but could you tell me where should I put the file name into the script that you sent to me?

A Cossa
Paul Hite
Trusted Contributor

Re: File Truncate

John, the semicolon is not guaranteed to be on the same line as "STORAGE".

Augusto, the script will read from standand in and write to standard out. So call the script "fixup" or something and then do:

fixup < inputfile > outputfile