Sponsored Content
Top Forums Shell Programming and Scripting Find the starting position in a file Post 302542003 by bobby1015 on Tuesday 26th of July 2011 10:59:17 AM
Old 07-26-2011
Quote:
Originally Posted by jim mcnamara
Your directions contradict each other. What EXACTLY determines the start and and of the account field?

It cannot be "MNT" that occurs at position 1 in both examples.
Well, I do apologise for giving you a hard time. Actually i was in a hurry

For file INPUT, it takes the following format
MNT-BANK-NUMBERO:006,00:N

MNT-515-ACCOUNT-NUMBERO:018,00:N

MNT-515-DESCRIPTIONO:045:C

For file OUTPUT, it takes the following format

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:

MON-BLK-ITEM-SEQ:006,00:N
MON-BLK-SEQ:004,00:N



Here, for the file INPUT we have 3 fields MNT-BANK-NUMBERO:006,00:N, MNT-515-ACCOUNT-NUMBERO:018,00:N and MNT-515-DESCRIPTIONO:045:C and so on.

For
MNT-BANK-NUMBERO:006,00:N field, the bank number is of 6(1-6) characters in length.
For
MNT-515-ACCOUNT-NUMBERO:018,00:N field, the account number is of 18(7-24) characters in length.

Here, for the file OUTPUT we have 2 fields MON-ACCOUNT:018,00:N, MON-BANK-NBR:006,00:N:018,00:N and so on.

For
MON-ACCOUNT:018,00:N field, the account number is of 18(86-103) characters in length.
For
MON-BANK-NBR:006,00:N:018,00:N field, the bank number is of 6(104-109) characters in length.

Now my requirment is to find the starting position of each BANK NUMBER and the ACCOUNT NUMBER side by side

Typical Output looks like this

INPUT,1,7,
OUTPUT, 86, 104

I hope this gives you a clear picture. If not please let me know. Thanks


---------- Post updated at 10:59 AM ---------- Previous update was at 10:44 AM ----------

Help Help Help

Last edited by bobby1015; 07-26-2011 at 11:54 AM..
 

10 More Discussions You Might Find Interesting

1. HP-UX

find the position in a file and insert the data there

Hi, I have a EDI data file ARROWTEST of size 18246 characters. And I want to insert some data after 4200 position in the file. How I can find the position 4200 in that file....Please advise. Regards, (5 Replies)
Discussion started by: isingh786
5 Replies

2. Shell Programming and Scripting

how to find a position and print some string in the next and same position

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

find if a position is between a given start and end position

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

How to put a word starting at particular position in a file using shell scripting

Hi all, I'm new to shell scripting and hence this query. I have 2 files. temp.txt and config.txt. The values in temp.txt are tab separated. ex: temp.txt AB CDE GHIJ OPQRS WXY ex:config.txt (1st line for 1st element of temp.txt and so on) start = '1' end='5' start = '6' end =... (26 Replies)
Discussion started by: subhrap.das
26 Replies

5. Shell Programming and Scripting

Find the position of a pattern on a line from a csv file

hello I'm doing a unix program and i'm using many file csv.in each csv file the colums are separated by ";" I would like to know the position of a pattern. For example for a line yyyy, bbbb, cccc; ddddd;eeee. I will like for example by finding the position of the pattern "cccc" and the response is... (6 Replies)
Discussion started by: papis
6 Replies

6. Shell Programming and Scripting

Remove the spaces at the end of a line starting from a fixed position

I want to remove the trailing spaces at the end of each line starting from a particular position(using ksh script). For example, in the attached file, I want to remove all the spaces starting from the position 430 till the end. The space has to be removed only from the 430th position no matter in... (3 Replies)
Discussion started by: Suryaaravindh
3 Replies

7. Shell Programming and Scripting

Grep starting from a specific position

Hello people, I'm scratch my head to find a solution to my problem, I'm absolutely sure this is very simple!!! :wall: I'm using the tcpdump to show on the screen in real time the UCP traffic: tcpdump -l -i bond1 -s 1514 -nntttt -A src or dst 192.168.1.5 and port 10000 | egrep "/51/"The output... (5 Replies)
Discussion started by: Lord Spectre
5 Replies

8. Shell Programming and Scripting

How to find character position in file?

how to find character positionin file? i.e string = "123X568" i want to find the position of character "X". Thanks (6 Replies)
Discussion started by: LiorAmitai
6 Replies

9. Shell Programming and Scripting

Find the position of a field/column in a flat file

Hi, Let say I have a file which has around 400 fields. SampleFile ========= PATIENTID|FACILITY|................|TIME_LAST_VISITED_BY_MD|.....|STATUS| How is it possible to find out which field is TIME_LAST_VISITED_BY_MD?fro example by seeing the above structure we can saw FACILITY... (5 Replies)
Discussion started by: machomaddy
5 Replies

10. Shell Programming and Scripting

Find position of character in multiple strings in a file

Greetings. I have a file with information like this: AMNDHRKEOEU?AMNDHRKEOEU?AMNDHRKEOEU?AMNDHRKEOEU? AMNDHRKEEU?AMNDHREOEU? AMNDHREU?AHRKEOEU?AMNDHRKEU?AMNDKEOEU? What I need to extract is the position, in every line, of every occurrence of '?' A desired output would be something... (6 Replies)
Discussion started by: Twinklefingers
6 Replies
All times are GMT -4. The time now is 08:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy