![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
| Display Modes | Rate This Thread |
|
|