Help need in Deleting Characters

Hi,

I have a log file whose size is number of characters in the file with multiple lines.

Example:
SQL*Loader: Release 10.2.0.4.0 - Production on Sat Sep 12 07:55:29 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Control File: ../adm/ctl/institution.ctl
Character Set WE8ISO8859P1 specified for all input.
Data File: /usr/home/dfusr/data/pe_proxy_master_2000_load_20090912075525.dat
Bad File: /usr/home/dfusr/data/bad/pe_proxy_master_2000_20090912075525.bad
Discard File: /usr/home/dfusr/data/bad/pe_proxy_master_2000_20090912075525.discard
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table PECDF.INSTITUTION_DF, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect

I want to delete some characters if the size of the file is greater that 32767. Delete all the characters after the 32767 i.e 32768 to last character in the file. The characters are in multiple lines.

Please advice or give me some sample code.

Thanks
Raj

Something like this?

awk '{n=n+length+1}
n <= 32767
n > 32767 {n-=length;print substr($0,1,(32767-n));exit}
' file

Hi,

What does it mean what is n and length in the sample.

Can you be specific please.

Thanks-
Rajesh

n is a variable to store the number of bytes that has been read.

length is a builtin function to get the bytes (length) of the current line.

Beside the length you have to add 1 byte for the newline.

you could always use dd:

  dd if=infile bs=32767 count=1 > newfile