Finding the length of a string in a field


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding the length of a string in a field
# 8  
Old 07-26-2011
Can you give us the raw data?
# 9  
Old 07-26-2011
INPUT:

1. RD07:


RPT-BANK-NUMBERO:006,00:N
RPT-515-ACCOUNT-NUMBERO:018,00:N
RPT-515-DESCRIPTIONO:045:C
RPT-515-FEE-INCOMEO:013,02:N
RPT-515-FEE-WAIVEDO:013,02:N
RPT-515-FREE-ITEMSO:010,00:N
RPT-515-NET-AMOUNT:013,02:N
RPT-515-ORGNO:006,00:N
RPT-515-POST-DATE:008Smilie
RPT-515-PRODUCTO:006,00:N
RPT-515-REGIONO:006,00:N
RPT-515-SEQ-NUMBER:010:C
RPT-515-SRC-1O:003:C
RPT-515-TCODE-1O:006,00:N
RPT-515-TOTAL-ITEMSO:010,00:N



2. RD08

D-CHECK-NUM:012:C
D-COMMENT-LINE1:020:C
D-COMMENT-LINE2:020:C
D-COMMENT-LINE3:020:C
D-TRAN-ORDER:012:C
MON-ACCOUNT:018,00:N
MON-BANK-NBR:006,00:N
MON-BLK-ITEM-SEQ:006,00:N
MON-BLK-SEQ:004,00:N
MON-EFFECTIVE-DATE:008Smilie
MON-ENTRY-CODE:006,00:N
MON-RUN-SHIFT:004,00:N
MON-SOURCE:003:C


OUTPUT:


RD07,1,6,7,24
RD08,103,108,85,102



where 1-6 and 103-108 are BANK No's and 7-24 and 85-102 are the ACCOUNT NO's.



Thanks


# 10  
Old 07-27-2011
Please tell me one thing.

Sorry but do you know first of all how you got the output from the input you provided ?

You mentioned:

Quote:
where 1-6 and 103-108 are BANK No's and 7-24 and 85-102 are the ACCOUNT NO's.
But where does 103-108 or 85-102 etc exists in your input?

It's not possible to resolve untill you provide the details properly.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding difference between two columns of unequal length

Hi, I have two files which look like this cat waitstate.txt 18.2 82.1 cat gostate.txt 5.6 5.8 6.1 6.3 6.6 6.9 7.2 7.5 (4 Replies)
Discussion started by: jamie_123
4 Replies

2. Shell Programming and Scripting

Replace a field with a character as per the field length

Hi all, I have a requirement to replace a field with a character as per the length of the field. Suppose i have a file where second field is of 20 character length. I want to replace second field with 20 stars (*). like ******************** As the field is not a fixed one, i want to do the... (2 Replies)
Discussion started by: gani_85
2 Replies

3. Shell Programming and Scripting

Finding the length of the longest column

Hi, I am trying to figure out how to get the length of the longest column in the entire file (because the length varies from one row to the other) I was doing this at first to check how many fields I have for the first row: awk '{print NF; exit}' file Now, I can do this: awk '{ if... (4 Replies)
Discussion started by: MIA651
4 Replies

4. Shell Programming and Scripting

Flat file-make field length equal to header length

Hello Everyone, I am stuck with one issue while working on abstract flat file which i have to use as input and load data to table. Input Data- ------ ------------------------ ---- ----------------- WFI001 Xxxxxx Control Work Item A Number of Records ------ ------------------------... (5 Replies)
Discussion started by: sonali.s.more
5 Replies

5. Shell Programming and Scripting

Finding the records with a specified length

I have a sample txt file which has different variable lengths of 2,10,3,15. What is the command that I need use in order to get the record count that has length '3' Thanks (3 Replies)
Discussion started by: bobby1015
3 Replies

6. UNIX for Dummies Questions & Answers

Read a string with leading spaces and find the length of the string

HI In my script, i am reading the input from the user and want to find the length of the string. The input may contain leading spaces. Right now, when leading spaces are there, they are not counted. Kindly help me My script is like below. I am using the ksh. #!/usr/bin/ksh echo... (2 Replies)
Discussion started by: dayamatrix
2 Replies

7. Shell Programming and Scripting

Help with finding length of a field

I have a pipe delimited file. I need to check that the first and second fields are 5 characters long and if not i need to append 0 in front of them to make them 5 characters long. can some body let mwe know how i can find the length of the two fields and then make them 5 characters long if they... (6 Replies)
Discussion started by: dsravan
6 Replies

8. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

9. UNIX for Dummies Questions & Answers

Validating fixed length field...

What's wrong with this part of my script? I just want to put each column from a fixed length file into a variable so I can validate each field later in the script. exec< myfile.dat while read afile; do a=`echo $(echo $afile |cut -c1-10)` echo "$a" b=`echo $(echo $afile |cut -c11-20)`... (12 Replies)
Discussion started by: giannicello
12 Replies

10. Shell Programming and Scripting

Finding out the length of a string held within a variable

:confused: Does anyone know which command I can use to find out the length of a string held within a variable? (5 Replies)
Discussion started by: dbrundrett
5 Replies
Login or Register to Ask a Question