Help with a Multiline Record - TechRepublic
General discussion
August 23, 2004 at 12:12 PM
vavazquez652

Help with a Multiline Record

by vavazquez652 . Updated 21 years, 9 months ago

I have a file with following content:

reference number: 2426
country : MY
request type : SUPPLIES REQUEST
request subtype : APT
new status : OPEN
priority : M
target completion : 2004-07-16
account type : A
account country : MY
account number : 550000055
account sequence : 11
company name : TEST
address : JHGJ
.
.
.
.
etc …

I need the information on column 3 or 4 that means by example:

2426
MY
SUPPLIES REQUEST
APT

And so on ….
But the script that a wrote send the following results:

1;2426|
2;MY|
3;SUPPLIES|
4;APT|
5;OPEN|
6;M|
7;2004-07-16|
8;A|
9;MY|
10;550000055|
11;11|
12;TEST|
13;JHGJ|

This is my Unix script:

awk -v data=0 -F”:” ‘{
if ($1==”reference number”) data = 1
if (data==1) print $2
if ($1~”CNEE TEL*”) data = 0
}
END {
print “@FIN”
} ‘ $1 | sed “s/^[ ][ ]*//” | awk ‘BEGIN {
IFS=”\n”
IRS=”@FIN”
OFS=”|”}
{
print NR “;” $1 “|” $3
}’ > data.txt

How can I obtain the following result

2426|MY|SUPPLIES REQUEST|APT|OPEN|M, etc ….

For your help thank you !!!

AVA
vavazquez65@hotmail.com

This discussion is locked

All Comments