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 > 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
append each line on fixed position 31 to 33 kshuser Shell Programming and Scripting 5 3 Weeks Ago 06:11 PM
append existing file with zeroes bsed on position kshuser Shell Programming and Scripting 3 3 Weeks Ago 04:39 PM
find if a position is between a given start and end position fadista UNIX for Dummies Questions & Answers 9 12-04-2008 12:17 PM
how to find a position and print some string in the next and same position naveenkcl Shell Programming and Scripting 1 08-21-2008 01:18 PM
Append line based on fixed position ashikin_8119 Shell Programming and Scripting 2 03-19-2008 04:09 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 2 Weeks Ago
new2ksh new2ksh is offline
Banned
  
 

Join Date: Nov 2009
Posts: 4
I have a file FILE1.DAT like below

21111111110001343 000001004OLF-AA029100020091112
21111111110000060 000001004ODL-CH001000020091112
24444444440001416 000001045OLF-AA011800020091112
23333333330001695 000001039OLF-AA030600020091112
23333333330000111 000001039ODL-SP002000020091112
23333333330000060 000001039ODL-CH001000020091112
22222222220000780 000001013OLF-AA006500020091112

i like to append the values only for the position 28:33
OLF-AA to OLF-1E
ODL-SP to ODL-2S
ODL-CH to ODL-3C

21111111110001343 000001004OLF-1E029100020091112
21111111110000060 000001004ODL-3C001000020091112
24444444440001416 000001045OLF-1E011800020091112
23333333330001695 000001039OLF-1E030600020091112
23333333330000111 000001039ODL-2S002000020091112
23333333330000060 000001039ODL-3C001000020091112
22222222220000780 000001013OLF-1E006500020091112

This i want in .KSH script, thanks in advance.

i have the following data in the FILE1

21111111110000204 000029148OLF-AA006300020091112
22222222220004038 000002304OLF-AA012500020091112 0003231 0000060
23333333330003265 000002315OLF-AA039300020091112 0000415
24444444440001344 000009896OLF-AA011200020091112 0000120
25555555550001778 000002331OLF-AA021400020091112
26666666660001098 000002336OLF-AA003400020091112 0000969
27777777770002653 000002349OLF-AA047900020091112
28888888880000636 000026198OLF-AA005300020091112
29999999990000244 000029309OLF-AA004800020091112
21231231230001440 000010268OLF-AA012000020091112 0001200
24564564560004404 000002368OLF-AA020300020091112

i like to append only those line having empty space for the position 50-56 & 58-64 with 7 zeros 0000000 (eg: record line 7, 8 & 9)

the outfile FILE2.txt should be like this

21111111110000204 000029148OLF-AA006300020091112 0000000 0000000
22222222220004038 000002304OLF-AA012500020091112 0003231 0000060
23333333330003265 000002315OLF-AA039300020091112 0000415 0000000
24444444440001344 000009896OLF-AA011200020091112 0000120 0000000
25555555550001778 000002331OLF-AA021400020091112 0000000 0000000
26666666660001098 000002336OLF-AA003400020091112 0000969 0000000
27777777770002653 000002349OLF-AA047900020091112 0000000 0000000
28888888880000636 000026198OLF-AA005300020091112 0000000 0000000
29999999990000244 000029309OLF-AA004800020091112 0000000 0000000
21231231230001440 000010268OLF-AA012000020091112 0001200 0000000
24564564560004404 000002368OLF-AA020300020091112 0000000 0000000

this i like to have in .KSH script

thxs in adv.

Last edited by vbe; 2 Weeks Ago at 02:00 PM..
  #2 (permalink)  
Old 2 Weeks Ago
Scrutinizer Scrutinizer is online now
Registered User
  
 

Join Date: Nov 2008
Posts: 601
Code:
sed 's/OLF-AA/OLF-1E/;s/ODL-SP/ODL-2S/;s/ODL-CH/ODL-3C/' infile
  #3 (permalink)  
Old 2 Weeks Ago
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,568
See:
append end of line with 8 spaces

Same user with total disrespect of forum rules: banned
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 04:18 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