Deleting all characters from 350th character to 450th character from the log file

Hi All,

I have a big log file i want to delete all characters (between 350th to 450th characters) starting at 350th character position to 450th character position.

please advice or sample code.

Is this is what you are looking for ?

sed 's/^\(.\{349\}\)\(.\{99\}\)\(.*\)/\1\3/' filename

or use cut:

cut -c1-349,451- file

Hi Thanks for your quick replay.

It is not deleting the charaters between nth character to nth character.

example:

123456789
abcdefghijklmnopqrst
xyzumnopqrst

i want to delete all character from k to n

please advice

Are all the log file records the same length? How many characters in each logfile record?

Following perl script will do the trick for you..

while(<>)  {
    $txt .= $_;
    $newline++;
    last if ( scalar split //, $txt ) >= ( 451 );
}

$txt =~ s/(.{350}).{100}/\1/s;

print $txt;
print while(<>);

Took a good amount of time to write & test...

Let me know the result.

Hi Methly,

Thanks for your response,

The log file length varies.

some log files are 32765 B and some are 58853.
But what i want to do is..

If log file size exceeds 32767 B i want to delete some characters from the file and decrease the file size.

Example:

[pe_proxy_master.sh]: Oct 09 09:08:40 : Recieved DB Credentials
[pe_proxy_master.sh]: Oct 09 09:08:42 : Message : SUCCESSFULLY FETCHED TASK ATTRIBUTES FOR JOBID: 2060
[pe_proxy_master.sh]: Oct 09 09:08:42 : Starting [pkg_proxy_datafeed_api.USP_PROXY_DEL_DF_ROWS] using [JOBID:2060||JOBNAME:AGENDA||RUNNUMBER:1]...

Procedure Successfully Updated data for Run Status Id 588

PL/SQL procedure successfully completed.

[pe_proxy_master.sh]: Oct 09 09:08:44 : Control File Received [/usr/home/dfusr/adm/ctl/agenda.ctl]...Starting Program....
[pe_proxy_master.sh]: Oct 09 09:08:44 : Data File Received [/usr/home/dfusr/data/agenda.dat]...Starting Program....
[pe_proxy_master.sh]: Oct 09 09:08:45 : Loading [AGENDA] using SQL-Loader...

SQL*Loader: Release 10.2.0.4.0 - Production on Fri Oct 9 09:08:45 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Commit point reached - logical record count 17
[pe_proxy_master.sh]: Oct 09 09:08:45 : >>>>> LOAD LOG [/tmp/pe_proxy_master.Fri.tmp] Content...<<<<<

SQL*Loader: Release 10.2.0.4.0 - Production on Fri Oct 9 09:08:45 2009

Copyright (c) 1982, 2007, Oracle. All rights reserved.

Control File: /usr/home/dfusr/adm/ctl/agenda.ctl
Character Set WE8ISO8859P1 specified for all input.

Data File: /usr/home/dfusr/data/pe_proxy_master_2060_load_20091009090839.dat
Bad File: /usr/home/dfusr/data/bad/pe_proxy_master_2060_20091009090839.bad
Discard File: /usr/home/dfusr/data/bad/pe_proxy_master_2060_20091009090839.discard
(Allow all discards)

Number to load: ALL
Number to skip: 0
Errors allowed: 17
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional

Table "PECDF"."AGENDA_DF", loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect

Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
JOB_NBR FIRST * | CHARACTER
ALT_JOB_NBR NEXT * | CHARACTER
SECURITY NEXT * | CHARACTER
SQL string for column : "LTRIM(RTRIM(:security))"
RECORD_DATE NEXT * | DATE RRRRMMDD
AGENDA_NBR NEXT * | CHARACTER
COMMITTEE_TYPE_CD NEXT * | CHARACTER
COMMITTEE_NUMBER NEXT * | CHARACTER
PROPOSAL_CATEGORY NEXT * | CHARACTER
PROPOSAL_NBR NEXT * | CHARACTER
PROPOAL_LABEL NEXT * | CHARACTER
PROP_TYPE_CD NEXT * | CHARACTER
PROP_MRV NEXT * | CHARACTER
PROP_VOTE_OPTION NEXT * | CHARACTER
PROPOSAL_TXT NEXT * | CHARACTER
SQL string for column : "TRIM(:proposal_txt)"
PROPOSAL_TXT_SEQ_NBR NEXT * | CHARACTER
APPOINTEES NEXT * | CHARACTER
SQL string for column : "LTRIM(RTRIM(:appointees))"
MAX_NBR_DIRECTOR NEXT * | CHARACTER
LANGUAGE_INDICATOR NEXT * | CHARACTER
JOB_TYPE NEXT * | CHARACTER

value used for ROWS parameter changed from 64 to 52

Table "PECDF"."AGENDA_DF":
17 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.

I want to delete from Number to load to null. in the last line.

Please advice.