Hi all,
I need help manipulating the file below.
Here is what I needed to do.
First, I have to replace INSUPD to DELETE.
Then I need to change the content of the file around by flipping the contents in the file from the bottom to the top (start from "CMD")
How should I attack this?
Here is the original file.
SET DECIMAL ,
SET DATAFORMAT DELIMITED
SET SEPARATOR ~
SET PREFIX DATA NONE
SET QUOTE NONE
SET DATEFORMAT DD-MM-YYYY
CMD INSUPD format
ATT code nature_e
INC /usr/tmp/FORMAT.fmt
CMD INSUPD format_element
ATT sqlname_c
INC /usr/tmp/FORMAT.elt
CMD INSUPD denomination format_element
ATT object_id
INC /usr/tmp/FORMAT.feden
CMD INSUPD script_definition
ATT attribute.sqlname_c
INC /usr/tmp/FORMAT.def
Here is what I want it to be.
SET DECIMAL ,
SET DATAFORMAT DELIMITED
SET SEPARATOR ~
SET PREFIX DATA NONE
SET QUOTE NONE
SET DATEFORMAT DD-MM-YYYY
CMD INSUPD script_definition
ATT attribute.sqlname_c
INC /usr/tmp/FORMAT.def
CMD INSUPD denomination format_element
ATT object_id
INC /usr/tmp/FORMAT.feden
CMD INSUPD format_element
ATT sqlname_c
INC /usr/tmp/FORMAT.elt
CMD INSUPD format
ATT code nature_e
INC /usr/tmp/FORMAT.fmt
Here is what I got so far.
#/bin/ksh
# Replacing INSUPD with DELETE
/bin/sed -e "s:INSUPD
ELETE:" /usr/tmp/XYZ_FILE.cmd | awk '{print};/INC .*.del/{exit}' > /usr/tmp/ XYZ_FILE.del.cmd
#end script