this my source file
************* fixed ***************
Begin
equipmentId : d9
processor : fox
number : bhhhhhh
Variable # 1:
Id : 100
Type : 9
nType : s
gType : 5f
mType : 4
LField : England
DataField : london
Length : 4
End
Variable # 2:
Id : 200
Type : 9
nType : f
gType : f
mType : 9
LField : England
DataField : london
Length : 4
End
Variable # 3:
Id : 400
Type : 7
nType : c
gType : r
mType : h
LField : Egypt
DataField : Cairo
Length : 4
End
Variable # 4:
Id : 515
Type : 7
nType : 1
gType : 5d
mType : 9a
LField : France
DataField : Paris
Length : 2
End
End of section.
************* fixed ***************
Begin
equipmentId : d9
processor : fox
number : bhhhhhh
Variable # 1:
Id : 515
Type : 9
nType : s
gType : 5f
mType : 4
LField : England
DataField : london
Length : 4
End
Variable # 2:
Id : 550
Type : 9
nType : f
gType : f
mType : 9
LField : France
DataField : Paris
Length : 4
End
Variable # 3:
Id : 600
Type : 7
nType : c
gType : r
mType : h
LField : Egypt
DataField : Cairo
Length : 4
End
End of section.
************* fixed ***************
Begin
equipmentId : d9
processor : fox
number : bhhhhhh
Variable # 1:
Id : 100
Type : 9
nType : s
gType : 5f
mType : 4
LField : England
DataField : london
Length : 4
End
Variable # 2:
Id : 516
Type : 9
nType : f
gType : f
mType : 9
LField : Egypt
DataField : Cairo
Length : 4
End
Variable # 3:
Id : 609
Type : 7
nType : c
gType : r
mType : h
LField : usa
DataField : NY
Length : 4
End
Variable # 4:
Id : 715
Type : 7
nType : 1
gType : 5d
mType : 9a
LField : germany
DataField : munich
Length : 2
End
End of section.
************* fixed ***************
Begin
equipmentId : d9
processor : fox
number : bhhhhhh
Variable # 1:
Id : 100
Type : 9
nType : s
gType : 5f
mType : 4
LField : England
DataField : london
Length : 4
End
End of section.
i`ve asked get a column getting ( DataField under ID : 515 or 516 ) in the variable part that its not in same place every time and variable fields are not of a fixed number and if he couldnt find ID 515 nor 516 return with ( not found )
thats mean our output
Paris
london
cairo
not found ....... as Id 515 not found nor 516
Chubler_xl got me this
nawk -v target=${1:-515} '
$1 == "End" && $2 == "of" {
if( value["Id"] == target )
print value["DataField"];
else print "Not Found";
split( "", value, "." );
}
$1 == "End" {snarf=0; next }
$1 == "Id" && $3 == target { snarf=1 }
snarf && $2 == ":" {value[$1] = $3}
' infile
this gets mee only id = 515 what if [ 516 and 515 ]
i tried to make it but nothing done please help as fast as possible