Urgent help !!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Urgent help !!!
# 1  
Old 10-20-2009
read the 2nd line in the dat file

Hi i am new to the unix ksh scripting.

I have a .DAT file like below assume file name is file.dat

1200812270046581
21234567890000652 B86860003OLF 592123320081227
21234567890000652 B86860003ODL-Sp592123420081227
21111111110000653-B94030001ODL-Ch592123520081227
30000005

there are 5 lines in the above file, the first digit in the
first line is no 1, no 1 represents Header
second line no2, no 2 represents Body
third line no2, no 2 represents Body
fourth line no2, no 2 represents Body
fifth line no3, no 3 reprents Trailer.

I want to read the second line leaving first digit 2 in the Body row.
eg: 21234567890000652,
I want output is 123456789 , again based on this output i want to get the string(position 28:33) "OLF " and keep this in variable again from the same 2nd line since the number is 123456789, i want to get the string "ODL-Sp"(position 28:33) this is also in 2nd variable, (then i want to append the same file above with 2 more columns in each record
1200812270046581
21234567890000652 B86860003OLF 592123320081227 5921233
21234567890000652 B86860003ODL-Sp592123420081227 5921234
......
) like wise for the 3rd line get the no (111111111)and for this number get the (position 28:33) "ODL-Ch" and append the 3rd line like this
21111111110000653-B94030001ODL-Ch592123520081227 5921235

It means i want a piece of code in .KSH shell file wherein it get the Number like 123456789,111111111,222222222 and based on this ssn no get the string (position 28:33) for each line and keep it in a variable both for multiple ssn records and single ssn records.

I want to read only the Body records line 2,3,4 &5.

Can someone really help me out on this. I really appreciate if someone can post the code in here.

thnkx

Last edited by kshuser; 10-20-2009 at 04:20 PM.. Reason: read the 2nd line in the dat file
# 2  
Old 10-20-2009
Hello,

Per our forum rules, all threads must have a descriptive subject text. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".

The reason for this is that nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, the subject field must be something useful and related to the problem!

In addition, current forum users who are kind enough to answer questions should be able to understand the essence of your query at first glance.

So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your subject text. You might receive a forum infraction if you don't pay attention to this.

Thank you.

The UNIX and Linux Forums
# 3  
Old 10-20-2009
Tools What have you tried?

While we like to help, we also like to know that we are not solving for you.
For instance, the grep command might be a place to start
> grep "^2"
on some input would select record lines that only begin with a 2
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

URGENT Reading a file and assessing the syntax shell script URGENT

I am trying to write a shell script which takes an input file as an arguement in the terminal e.g. bash shellscriptname.sh input.txt. I would like for the file to be read line by line each time checking if the .txt file contains certain words or letters(validating the syntax). If the line being... (1 Reply)
Discussion started by: Gurdza32
1 Replies

2. Shell Programming and Scripting

Urgent !!

Hello All, I want to use scp for copying multiple files ( files locations are stored in an array ) from remote server from different locations without prompting password every time . I will supply password once and it should be able to copy every file mentioned in an array. eg :- array have ... (1 Reply)
Discussion started by: manpav
1 Replies

3. Shell Programming and Scripting

Need urgent help

Hi geeks, I'm trying to write a below script, but it throws an error, please check and correct me. #!/bin/bash #The below script will extract the string error1 error2 and error3 and also it will count and list the occurrence count1='grep -i "error1" test.txt | wc -l' count2='grep -i "error2"... (4 Replies)
Discussion started by: naren nandale
4 Replies

4. Shell Programming and Scripting

Need Urgent help

Hi friends, I need urgent help here: Issue: I need to create shell script that will find the files & throw an error through job (autosys) when file not found. Daily we use to receive 3 files from a system. Obstacles: 1) All 3 files names are same. 2) Timestamp is same. 3)... (1 Reply)
Discussion started by: tush
1 Replies

5. Shell Programming and Scripting

Urgent!!

Hi I have a file containing DE 3'UTR in Homo sapiens alpha-1-B glycoprotein (A1BG), mRNA. SQ Sequence 216 BP; 37 A; 58 C; 69 G; 52 T; 0 other; DE 3'UTR in Homo sapiens alpha-1-B glycoprotein (A1BG), mRNA. SQ Sequence 1844 BP; 358 A; 483 C; 434 G; 569 T; 0 other; DE 3'UTR in Homo... (1 Reply)
Discussion started by: jyotirmoy21
1 Replies

6. Red Hat

urgent

abb 117.96.113.21 cgg 101.2.104.42 cgg 110.227.247.236 desk 203.20.35.28 png 1.39.242.241 png 1.39.242.241 rzx 101.2.104.42 rzx 115.246.160.36 abb 49.138.242.187 how to find the count of this file wtrto ip thnx in advance (4 Replies)
Discussion started by: himanshu1.singh
4 Replies

7. UNIX for Advanced & Expert Users

need help urgent...........

Hi friends.. I am using the below command to search few files from many folders which is under one folder.. i mean let say the path is A/B/C...and inside C...i have 1-10 folder... the below command is working fine.... for i in 1 3 5 7; do find /A/B/C/${i} -name "*.txt" -o -name "*.csv"... (3 Replies)
Discussion started by: sapan123
3 Replies

8. UNIX for Advanced & Expert Users

URGENT,URGENT- Need help tape drive installation

Hi, I am trying to attach tape drive to sun V890 running Solaris 9 on it. I have installed HBA(qlogic) in slot 1 of 0-8 slots and booted the system. I do not see HBAin prtdiag output. The tape drive is not attached to HBA. The tape drive I am going to attach is Sony AIT3. 1.How can I make... (3 Replies)
Discussion started by: sriny
3 Replies

9. Solaris

Need Help Urgent

Hi. My E250 server (Solaris 8) running oracle database gets hangup in between. I checked the logs in /var/adm/messages but could not find anything related to this. can anyone help me out? bala (3 Replies)
Discussion started by: balaji_prk
3 Replies
Login or Register to Ask a Question