05-16-2008
how to read record by record from a file in unix
Hi guys,
i have a big file with the following format.This includes header(H),detail(D) and trailer(T) information in the file.My problem is i have to search for the character "6h" at 14 th and 15 th position in all the records .if it is there i have to write all those records into a separate file along with the header and trailer and the last nine digits in the trailer should indiacate the count of the detaied records.can any one help me on this how to achive? Basically i am new to unix shell scripting.
following the file format is
HBM6303000000000200805060940412008050609404120080506SCITS 8.2
D6303200805066HJ8164-61002 EURO6303I0073554514 0017992008031120080430HP00DD00Hewlett-Packard Pte Ltd 12.000 20080502 0000000509.3900UDNB USDEA 00001EA SG 00022797990001 00000120080226 0073554514 6303 N101 HP00DD00 20080503 00022797990001
D6303200805066HJ8164-61002 EURO6303I0073554514 0018052008031120080430HP00DD00Hewlett-Packard Pte Ltd 16.000 20080502 0000000509.3900UDNB USDEA 00001EA SG 00022798050001 00000120080226 0073554514 6303 N101 HP00DD00 20080503 00022798050001
D6303200805066HJ8164-61002 EURO6303I0073554514 0018142008031120080430HP00DD00Hewlett-Packard Pte Ltd 16.000 20080502 0000000509.3900UDNB USDEA 00001EA SG 00022798140001 00000120080226 0073554514 6303 N101 HP00DD00 20080503 00022798140001
D6303200805066HJ8164-61002 EURO6303I0073554514 0018092008031120080430HP00DD00Hewlett-Packard Pte Ltd 16.000 20080502 0000000509.3900UDNB USDEA 00001EA SG 00022798090001 00000120080226 0073554514 6303 N101 HP00DD00 20080503 00022798090001
TBM630300000000020080506094041000003818
advancedthanks
narasimha.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all
I have file f1 like this:
Set AM/PM indicator to PM started|14155|
Generate Error Re|7|
Projected Cash Ba|741|
Roll System Date |4|
Projected Cash Balances started|2|
Process Mark To Market started|13429|
Process paydowns started|14189|
Process Fixed Inc|439|
Process Mark To... (3 Replies)
Discussion started by: koti_rama
3 Replies
2. Shell Programming and Scripting
Hi,
I am new to UNIX scripting and woiuld appreicate your help...
Input file contains only one (but long) record:
aaaaabbbbbcccccddddd.....
Desired file:
NEW RECORD #new record (hardcoded) added as first record - its length is irrelevant#
aaaaa
bbbbb
ccccc
ddddd
...
...
... (1 Reply)
Discussion started by: rsolap
1 Replies
3. UNIX for Advanced & Expert Users
Hi
I have an xml file which has multiple xml records..
I don't know how to read those records and pipe them to another shell command
the file is like
<abc>z<def>y<ghi>x........</ghi></def></abc> (1st record)
<jkl>z<mno>y<pqr>x........</pqr></mno></jkl> (2nd record)
Each record end... (4 Replies)
Discussion started by: aixjadoo
4 Replies
4. Shell Programming and Scripting
Hi
I want to read one row record from a text file.
For eg: I have Sample.txt file with one row of record like
123456768
I want to get the above value from the file and assign it to a variable in my script. Please guide me how to proceed.
Thanks,
Soll (2 Replies)
Discussion started by: sollins
2 Replies
5. Shell Programming and Scripting
Hi Guys,
I am new to unix scripting and I am tasked to parse through a CSV file delimited by #.
Sample:
sample.csv
H#A#B#C
D#A#B#C
T#A#B#C
H = Header
D = Detail Record
T = Tail
What I need is to read the file and parse through it to get the columns.
I have no idea on how... (8 Replies)
Discussion started by: 3vilwyatt
8 Replies
6. Shell Programming and Scripting
For eg: I have sample.txt file with 4 rows of record like:
user1|password1
user2|password2
user3|password3
user4|password4
The username and password is sepsrated by '|'
I want to get the 1st row value from the file and assign it to two different variables(username and password)
in my... (1 Reply)
Discussion started by: priya001
1 Replies
7. Shell Programming and Scripting
Hi,
I am reading file records inside a while loop,
and want to update the record when certain condition is met.
How can I update a file while being read?
I want to avoid using temporary files, copy, rename, ...
while IFS=',' read -r f1 f2
do
function(f1,f2)
if
then
<add... (1 Reply)
Discussion started by: ysrini
1 Replies
8. Shell Programming and Scripting
Hi! all
can any one tell me how to compare current record of column with next and previous record in awk without using array
my case is like this
input.txt
0 32
1 26
2 27
3 34
4 26
5 25
6 24
9 23
0 32
1 28
2 15
3 26
4 24 (7 Replies)
Discussion started by: Dona Clara
7 Replies
9. Shell Programming and Scripting
Hello, I have a file that looks like this:
Generated geometry (...some special descriptor)
1 0.56784 1.45783 -0.87965
8 1.29873 -0.8767 1.098789
... ... ... ...
Generated geometry (....come special descriptor)
... .... ... ...
... ... ... ...
and... (4 Replies)
Discussion started by: jaldo0805
4 Replies
10. Shell Programming and Scripting
I have test.xml
<emp><id>101</id><name>AAA</name><date>06/06/14 1811</date></emp>
<Join><id>101</id><city>london</city><date>06/06/14 2011</date></join>
<Join><id>101</id><city>new york</city><date>06/06/14 1811</date></join>
<Join><id>101</id><city>sydney</city><date>06/06/14... (2 Replies)
Discussion started by: vsraju
2 Replies
LEARN ABOUT REDHAT
ssl_rstate_string
SSL_rstate_string(3) OpenSSL SSL_rstate_string(3)
NAME
SSL_rstate_string, SSL_rstate_string_long - get textual description of state of an SSL object during read operation
SYNOPSIS
#include <openssl/ssl.h>
const char *SSL_rstate_string(SSL *ssl);
const char *SSL_rstate_string_long(SSL *ssl);
DESCRIPTION
SSL_rstate_string() returns a 2 letter string indicating the current read state of the SSL object ssl.
SSL_rstate_string_long() returns a string indicating the current read state of the SSL object ssl.
NOTES
When performing a read operation, the SSL/TLS engine must parse the record, consisting of header and body. When working in a blocking envi-
ronment, SSL_rstate_string[_long]() should always return "RD"/"read done".
This function should only seldom be needed in applications.
RETURN VALUES
SSL_rstate_string() and SSL_rstate_string_long() can return the following values:
"RH"/"read header"
The header of the record is being evaluated.
"RB"/"read body"
The body of the record is being evaluated.
"RD"/"read done"
The record has been completely processed.
"unknown"/"unknown"
The read state is unknown. This should never happen.
SEE ALSO
ssl(3)
0.9.7a 2001-08-23 SSL_rstate_string(3)