Sponsored Content
Top Forums Shell Programming and Scripting File splitting according to the length of the fields Post 302946438 by RudiC on Tuesday 9th of June 2015 09:12:04 AM
Old 06-09-2015
Any ideas / attempts from your side?

---------- Post updated at 15:12 ---------- Previous update was at 14:52 ----------

However, try
Code:
awk '
NR < 3          {next}
NR == FNR       {HD=HD DL $1; DL=","
                 Pos[++n]=$2+$3
                 next}
FNR == 1        {print HD; next}
                {for (i=n; i>0; i--) $(Pos[i])=DL $(Pos[i]) }
1
' info FS="" OFS="" data
ADJ-TYPE-CODE,ALLOW-AMT,CAP-SRVC-NO,BILL-AMT
R,-0000017611,N,-0000035000,1095ANZU01
A,00000017611,N,00000035000,1095ANZU02
R,-0000019427,N,-0000026500,1202BGYI03
R,-0000005977,N,-0000009200,1202BGYI03
R,-0000017195,N,-0000099500,1353B1IZ03
A,00000099500,N,00000099500,1353B1IZ04
R,-0000258547,N,-0000226600,2019AXAJ01
A,00000258547,N,00000226600,2019AXAJ02
R,-0000012277,N,-0000021600,2026BLCF03
A,00000012277,N,00000021600,2026BLCF04


Last edited by RudiC; 06-09-2015 at 10:29 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help in splitting a line into fields in shell scripting

I have a line of more than 3000 bytes which will contain & as fields separator..I am using following awk command ..Its working but its not accepting the line more than 3000 bytes...Anyother alternate solution even in othe shell command also fine... awk -F '&' '{for( i=1; i<=NF; i++ ) print $i}'... (2 Replies)
Discussion started by: punithavel
2 Replies

2. Shell Programming and Scripting

Need awk script to compare 2 fields in fixed length file.

Need a script that manipulates a fixed length file that will compare 2 fields in that file and if they are equal write that line to a new file. i.e. If fields 87-93 = fields 119-125, then write the entire line to a new file. Do this for every line in the file. After we get only the fields... (1 Reply)
Discussion started by: Muga801
1 Replies

3. Shell Programming and Scripting

Fixed length fields

HPUX and posix shell Hi all. I have a record with fixed length fields....I would like to reorder the fields and preserver the fixed lengths.... cat test 4 960025460 Dept of Music 8 960025248 Dept of Music 12-08 cat... (3 Replies)
Discussion started by: lyoncc
3 Replies

4. Shell Programming and Scripting

Help with splitting fields

Hi. I want to put the first field to the end and the lines are of different number of fields. How should I do this with awk? Thanks. (3 Replies)
Discussion started by: dustinwang2003
3 Replies

5. Shell Programming and Scripting

Splitting fixed length file using awk

Hi, I need to split a fixed length file of 160 characters based on value of a column. Example: ABC 456780001 DGDG SDFSF BCD 444440002 SSSS TTTTT ABC 777750003 HHHH UUUUU THH 888880001 FFFF LLLLLL HHH 999990002 GGGG OOOOO I need to split this file on basis of column from... (7 Replies)
Discussion started by: Neelkanth
7 Replies

6. Shell Programming and Scripting

Splitting a column in two separate fields

for making a summary I have a CSV file which is transformed to .DAT. I have an AWK file which is supposing to do the mapping of the DAT file. The code from the AWK file is the one below. The content of the DAT file looks like this (tab separated): ODT AGE CDT CO SEX TIME VALUE COMMENT ... (1 Reply)
Discussion started by: grikoss
1 Replies

7. Shell Programming and Scripting

Help in splitting Sub Fields and compare with other field

Hi All, We are trying to pull out data from below table, the table contains four fields and out of which last two fields are having sub-fields with delimiter $, we want to identify number "1" position in the 3rd field and from 4th field need to extract the information from the same position. ... (4 Replies)
Discussion started by: rramkrishnas
4 Replies

8. Shell Programming and Scripting

Splitting a filed into multiple fields using awk

Hi, I have a tab delimited file as below: AWA Divi DD01 None 1 2 Room AC 01-MAY-15 31-OCT-15 OT 01-MAY-15 31-OCT-15 CF 01-MAY-15 31-OCT-15 AW0 Beach DD02 None 1 2 Double AC 01-MAY-15 31-OCT-15 AD 01-MAY-15 31-OCT-15 The number of columns(fields) after 7th field is not fixed and... (3 Replies)
Discussion started by: Bobby_2000
3 Replies

9. Shell Programming and Scripting

Splitting multiple fields of /usr/bin/id

Hi, Iv got the following input $id |grep uid uid=6090(dsiddiq) gid=1(staff) groups=4001(cdgrp) and Im using the below command to split the field to grab the numberical userid as well the alphabetical userid $id|awk -F'=' '{print $2}'|awk -F')' '{print $1}'|awk -F'(' '{print $1" "$2}'... (4 Replies)
Discussion started by: dsid
4 Replies

10. UNIX for Beginners Questions & Answers

Splitting the file based on two fields - Fixed length file

Hi , I am having a scenario where I need to split the file based on two field values. The file is a fixed length file. ex: AA0998703000000000000190510095350019500010005101980301 K 0998703000000000000190510095351019500020005101480 ... (4 Replies)
Discussion started by: saj
4 Replies
wxComboBox(3erl)					     Erlang Module Definition						  wxComboBox(3erl)

NAME
wxComboBox - See external documentation: wxComboBox. DESCRIPTION
See external documentation: wxComboBox . This class is derived (and can use functions) from: wxControlWithItems wxControl wxWindow wxEvtHandler DATA TYPES
wxComboBox() : An object reference, The representation is internal and can be changed without notice. It can't be used for comparsion stored on disc or distributed for use on other nodes. EXPORTS
new() -> wxComboBox() See external documentation . new(Parent::wxWindow() (see module wxWindow), Id::integer()) -> wxComboBox() Equivalent to new(Parent, Id, []) . new(Parent::wxWindow() (see module wxWindow), Id::integer(), Options::[Option]) -> wxComboBox() Types Option = {value, string()} | {pos, {X::integer(), Y::integer()}} | {size, {W::integer(), H::integer()}} | {choices, [[string()]]} | {style, integer()} | {validator, wx() (see module wx)} See external documentation . create(This::wxComboBox(), Parent::wxWindow() (see module wxWindow), Id::integer(), Value::string(), Pos::{X::integer(), Y::integer()}, Size::{W::integer(), H::integer()}, Choices::[[string()]]) -> bool() Equivalent to create(This, Parent, Id, Value, Pos, Size, Choices, []) . create(This::wxComboBox(), Parent::wxWindow() (see module wxWindow), Id::integer(), Value::string(), Pos::{X::integer(), Y::integer()}, Size::{W::integer(), H::integer()}, Choices::[[string()]], Options::[Option]) -> bool() Types Option = {style, integer()} | {validator, wx() (see module wx)} See external documentation . canCopy(This::wxComboBox()) -> bool() See external documentation . canCut(This::wxComboBox()) -> bool() See external documentation . canPaste(This::wxComboBox()) -> bool() See external documentation . canRedo(This::wxComboBox()) -> bool() See external documentation . canUndo(This::wxComboBox()) -> bool() See external documentation . copy(This::wxComboBox()) -> ok See external documentation . cut(This::wxComboBox()) -> ok See external documentation . getInsertionPoint(This::wxComboBox()) -> integer() See external documentation . getLastPosition(This::wxComboBox()) -> integer() See external documentation . getValue(This::wxComboBox()) -> string() See external documentation . paste(This::wxComboBox()) -> ok See external documentation . redo(This::wxComboBox()) -> ok See external documentation . replace(This::wxComboBox(), From::integer(), To::integer(), Value::string()) -> ok See external documentation . remove(This::wxComboBox(), From::integer(), To::integer()) -> ok See external documentation . setInsertionPoint(This::wxComboBox(), Pos::integer()) -> ok See external documentation . setInsertionPointEnd(This::wxComboBox()) -> ok See external documentation . setSelection(This::wxComboBox(), N::integer()) -> ok See external documentation . setSelection(This::wxComboBox(), From::integer(), To::integer()) -> ok See external documentation . setValue(This::wxComboBox(), Value::string()) -> ok See external documentation . undo(This::wxComboBox()) -> ok See external documentation . destroy(This::wxComboBox()) -> ok Destroys this object, do not use object again AUTHORS
<> wxErlang 0.98.9 wxComboBox(3erl)
All times are GMT -4. The time now is 05:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy