Editing long records with characters that need to be escaped.

Hi all,

I'm new in unix scripting and I've a problem with a script... :confused:

I need to read a file, add some fields in the records, and write them in another file, but even when I simply read and write the records, the shell interprets some caracters and the result is that the records get splitted on multiples lines, loosing that characters.

For example:

for cur_line in `cat "$fil"`
do
echo "$cur_line"
done;

In each record I can find any type of special characters: like " ' & ; , and so on...

Maybe someone can help me... :frowning: I hope I've been clear enough, although my english...
Thank a lot.

Macs,

can u just put that sample file so that i can know where it's going wrong.

This could be an example of a record I have to work with:

2009-07-20 17:18:03.0,"15.134.13.45.13","XXXXXX","15.134.13.45.13","xxxxxxx.xxxxxxx.IT","PIN6","SQLPLUS","PFZ5","SELECT","SIP_JDSIS3_T","IFRI","='3435354454334'","select PfrfID_ID0, substr(IFRI,1,15) IFRI2, substr(ORIGINARY_IFRI,1,15) ""TO_CHAR(CAST((( TIMESTAMP '1970-01-01 00:00:00 GMT' + numtodsinterval(ROUND(CREATED_T), 'SECOND') ) at TIME ZONE 'MET') AS DATE), 'DD/MM/YYYY HH24:MI.SS') CREATED,  TO_CHAR(CAST((( TIMESTAMP '1970-01-01 00:00:00 GMT' + numtodsinterval(ROUND(CREATION_DATE), 'SECOND') ) at TIME ZONE 'MET') AS DATE), 'DD/MM/YYYY HH24:MI.SS') CREAT_DATE,  TO_CHAR(CAST((( TIMESTAMP '1970-01-01 00:00:00 GMT' + numtodsinterval(ROUND(MOD_T), 'SECOND') ) at TIME ZONE 'MET') AS DATE), 'DD/MM/YYYY HH24:MI.SS') from SIP_IFR03_T where IORI='3653453437941'","1"

I read it from a csv file in UNIX format.
The result of the simple script example I posted before is that this informations are printed in multiple lines... and some caracters are disappearing, so I have no possibility to work with it...

I really have no idea......

Thank you!

---------- Post updated at 03:00 PM ---------- Previous update was at 02:56 PM ----------

My intention was to use the pattern "," as separator for the field and add an empty field where it needs it, with awk.

But Double Quote are disappearing...And the single record is splitted in little parts...

mmm...

No ideas?
:frowning:

Your problem is directly related to the "^L" character. This is the ascii character for "Form feed, page eject".
Char: FF
Oct: 14
Dec: 12
Hex: c
Control-Key: ^L

Thank you for the info, I'll search something about it.

:slight_smile: