The UNIX and Linux Forums  

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
awk script to update header record klut Shell Programming and Scripting 5 04-16-2008 06:04 AM
How to extract duplicate records with associated header record run_eim UNIX for Dummies Questions & Answers 17 01-16-2007 08:46 PM
Need to Chop Header and Footer record from input file coolbudy Shell Programming and Scripting 4 08-09-2005 09:26 AM
awk: record has too many fields chaandana Shell Programming and Scripting 3 07-29-2005 10:03 AM
reconstructing a record in a diffrent order r1500 UNIX for Dummies Questions & Answers 1 10-16-2003 02:24 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-22-2008
Registered User
 

Join Date: Jan 2008
Posts: 5
change order of fields in header record

Hello,
after 9 months of archiving 1000 files,
now, i need to change the order of fields in the header record.
some very large, space padded files.
HEADERCAS05212008D0210DOMEST01(spacepadded to record length 210)
must now be
05212008HEADERCASD0210DOMEST01(spacepadded to record length 210)

Does anyone know a way to manipulate the first record only and resave the file?

I appreciate your time and expertise
Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 05-22-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,328
An example how you can achieve that:

Code:
awk 'NR==1{print substr($0,10,8) substr($0,1,9) substr($0,18);next}1' file > file_temp
mv file_temp file
Regards
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0