11-06-2009
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; 11-06-2009 at 02:00 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all;
I'm having headache on append one line to another based on the fix position.Hope u guys can help.
All i need to do is append the line that start with '3' to a line which start with '1' and the position for line 3 that i need to append is 22.
The original file look like this:
... (2 Replies)
Discussion started by: ashikin_8119
2 Replies
2. Shell Programming and Scripting
I need a script for...
how to find a position of column data and print some string in the next line and same position
position should find based on *HEADER8* in text
for ex: ord123 abs 123 987HEADER89 test234
ord124 abc 124 987HEADER88 test235
... (1 Reply)
Discussion started by: naveenkcl
1 Replies
3. UNIX for Dummies Questions & Answers
Hi,
I am a newbie in unix programming so maybe this is a simple question.
I would like to know how can I make a script that outputs only the values that are not between any given start and end positions
Example
file1:
2 30
40 80
82 100
file2:
ID1 1
ID2 35
ID3 80
ID4 81
ID6... (9 Replies)
Discussion started by: fadista
9 Replies
4. Shell Programming and Scripting
Hi i am trying to append value with 0 to an existing file in the position 50-56 & 58-64 only where empty space is there
Rule:
1 row already has some value and i do not want to change anything for this row.
2nd record below you see the position 50-64 is empty, i want to replace with 0000000... (3 Replies)
Discussion started by: kshuser
3 Replies
5. Shell Programming and Scripting
I have a .DAT file like below.
26666666660001343 000001004OLF 029100020090820
27777777770000060 000001004ODL-CH001000020090820
28888888880000780 000001013OLF 006500020090820
.......
........
and so on.....
I want to append each line in a file in .KSH script with XXX with position... (5 Replies)
Discussion started by: kshuser
5 Replies
6. Shell Programming and Scripting
hi,
I have a file which consists of some records:
2010_06_4010093_001_001|10|ABCDEFGH|9|4010093||0040400||31.12.2009|S|O|X||||20100602093851-31.12.2009|XXBBFC|EFG||||00001|
2010_06_4010162_001_001|11|ABCDEFGH|9|4010162||0040400||31.12.2009|S|O|X||||20100602093851-31.12.2009|XXBBFC|EFG||||00002|... (11 Replies)
Discussion started by: pparthiv
11 Replies
7. Shell Programming and Scripting
I want to remove text from nth position to nth position couple of times in same line
my line is
"hello is there anyone can help me with this question"
I need like this
ello is there anyone can help me with question
'h' is removed and 'this' removed from the line. I want to do this... (5 Replies)
Discussion started by: elamurugu
5 Replies
8. Shell Programming and Scripting
hi guys,
i want command or script to display the content of file from 2nd position to last but one position of a file
abcdefghdasdasdsd
123,345,678,345,323
434,656,656,656,656
678,878,878,989,545
4565656667,65656
i want to display the same above file without first and... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies
9. Shell Programming and Scripting
Hi,
I have a file with multiple lines(fixed width dat file). I want to search for '02' in the positions 45-46 and if available, in that lines, I need to replace value in position 359 with blank. As I am new to unix, I am not able to figure out how to do this. Can you please help me to achieve... (9 Replies)
Discussion started by: Pradhikshan
9 Replies
10. Shell Programming and Scripting
Hi All,
I wanted a sed/awk command to add a value/character on a particular position without disturbing the position of other characters.
I have file a.txt
OL 10031 Day Black Midi Good Value P01 P07
OL 10031 Day Black Short Good Value P01 P07
I want to get the output as... (2 Replies)
Discussion started by: rahulsk
2 Replies
LEARN ABOUT DEBIAN
json_pp
JSON_PP(1) Perl Programmers Reference Guide JSON_PP(1)
NAME
json_pp - JSON::PP command utility
SYNOPSIS
json_pp [-v] [-f from_format] [-t to_format] [-json_opt options_to_json]
DESCRIPTION
json_pp converts between some input and output formats (one of them is JSON). This program was copied from json_xs and modified.
The default input format is json and the default output format is json with pretty option.
OPTIONS
-f
-f from_format
Reads a data in the given format from STDIN.
Format types:
json
as JSON
eval
as Perl code
-t
Writes a data in the given format to STDOUT.
null
no action.
json
as JSON
dumper
as Data::Dumper
-json_opt
options to JSON::PP
Acceptable options are:
ascii latin1 utf8 pretty indent space_before space_after relaxed canonical allow_nonref
allow_singlequote allow_barekey allow_bignum loose escape_slash
-v
Verbose option, but currently no action in fact.
-V
Prints version and exits.
EXAMPLES
$ perl -e'print q|{"foo":"XX","bar":1234567890000000000000000}|' |
json_pp -f json -t dumper -json_opt pretty,utf8,allow_bignum
$VAR1 = {
'bar' => bless( {
'value' => [
'0000000',
'0000000',
'5678900',
'1234'
],
'sign' => '+'
}, 'Math::BigInt' ),
'foo' => "x{3042}x{3044}"
};
$ perl -e'print q|{"foo":"XX","bar":1234567890000000000000000}|' |
json_pp -f json -t dumper -json_opt pretty
$VAR1 = {
'bar' => '1234567890000000000000000',
'foo' => "x{e3}x{81}x{82}x{e3}x{81}x{84}"
};
SEE ALSO
JSON::PP, json_xs
AUTHOR
Makamaka Hannyaharamitu, <makamaka[at]cpan.org>
COPYRIGHT AND LICENSE
Copyright 2010 by Makamaka Hannyaharamitu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2014-09-30 JSON_PP(1)