The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to copy Content of a file to another file on a specific column tuxus Shell Programming and Scripting 8 08-14-2009 10:18 AM
Changing one column of delimited file column to fixed width column manneni prakash Shell Programming and Scripting 5 06-22-2009 06:27 AM
copy column to another file penlok UNIX for Dummies Questions & Answers 1 07-07-2008 03:29 PM
copy contents of one column in another raman1605 Shell Programming and Scripting 4 05-12-2008 09:58 AM
extracting/copy a column into a new column folashandy UNIX for Advanced & Expert Users 1 02-21-2008 01:24 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 4 Weeks Ago
kshuser kshuser is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 30
sed copy column value add to certain area

I have a base file FILE1 with the following data

FILE1.dat

Code:
21111111110001343 000001004OLFXXX029100020091112
21111111110000060 000001004ODL-CH001000020091112
22222222220000780 000001013OLFXXX006500020091112
23333333330001695 000001039OLFXXX030600020091112
23333333330000111 000001039ODL-SP002000020091112
23333333330000060 000001039ODL-CH001000020091112
24444444440001416 000001045OLFXXX011800020091112

......
......
..etc

i want to write a program in .KSH that the FILE2.dat should have only 4 unique records like below appending two new columns spouse_col & child_col at the end of each line based on position.
Remember this should be in while read line do loop

Code:
ODL-Ch = child_col , 
ODL-Sp = spouse_col
 
if ODL-SP then grab position 11-18 and copy to the position 50-57
elif ODL-CH then grab position 11-18 and copy to the position 58-65
fi

FILE2.DAT
blue color is mapped to spouse_column and red color mapped to child_column


Code:
21111111110001343 000001004OLFXXX029100020091112 0000000 0000060
22222222220000780 000001013OLFXXX006500020091112 0000000 0000000
23333333330001695 000001039OLFXXX030600020091112 0000111 0000060
24444444440001416 000001045OLFXXX011800020091112 0000000 0000000

thanks

Last edited by pludi; 4 Weeks Ago at 05:27 PM.. Reason: code tags, please...
 

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 08:21 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