The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
reading ,writing,appending ,manipulating a file. szchmaltz UNIX for Dummies Questions & Answers 4 06-17-2008 03:02 AM
Manipulating a fixed length file w/o PERL dabear Shell Programming and Scripting 4 03-31-2008 05:33 PM
Manipulating File rivendell500 SUN Solaris 2 03-25-2008 10:52 PM
Manipulating a text file komalkg Shell Programming and Scripting 6 06-24-2007 07:15 AM
Manipulating output file mariner UNIX for Advanced & Expert Users 1 04-20-2005 09:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-16-2008
sirrtuan sirrtuan is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 18
Help!! manipulating file

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:INSUPDELETE:" /usr/tmp/XYZ_FILE.cmd | awk '{print};/INC .*.del/{exit}' > /usr/tmp/ XYZ_FILE.del.cmd

#end script

Last edited by sirrtuan; 07-16-2008 at 06:37 PM..
  #2 (permalink)  
Old 07-16-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
By 'flipping around' if you mean fully reversing the order of and you are on linux try the tac command --
Code:
grep '^SET ' filename > newfile
sed -n '/^SET/,/$/p' filename | tac -  >> newfile
  #3 (permalink)  
Old 07-16-2008
sirrtuan sirrtuan is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 18
I want to move section 1 to 3 and via versa.
Here is an example:

1) CMD INSUPD format
ATT code nature_e
INC /usr/tmp/FORMAT.fmt

2) CMD INSUPD format_element
ATT sqlname_c
INC /usr/tmp/FORMAT.elt

3) CMD INSUPD denomination format_element
ATT object_id
INC /usr/tmp/FORMAT.feden

Last edited by sirrtuan; 07-16-2008 at 06:38 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0