Hi,
I have a tmp file like below:
<ADATA>
ANUM=900
ADESC=Saving
ATYP=0
TXREGD=0
</ADATA>
<ADATA>
ANUM=890
ADESC=Saving
ATYP=0
ABAL=9000
TXREGD=1
</ADATA>
<ADATA>
ANUM=900
ADESC=Check
ATYP=1
</ADATA>
<ADATA>
ANUM=890
ADESC=Saving
ATYP=0
ABAL=9000
TXREGD=1
</ADATA>
From above <ADATA> and </ADATA> container, I need ANUMs which has TXREGD only.
awk '
BEGIN { RS=""; ORS = "\n\n" }
/TXREGD/ ' "$FILENAME"
I am new to Unix, can you please explain me what is RS and ORS stands for.
I need ANUMS and TXREGD fields from each <ADATA> and </ADATA> container.
Record Separator and Output Record Separator
awk '
BEGIN { RS="" }
/TXREGD/ ' "$FILENAME" | grep -e ANUMS -e TXREGD
cat tmp.file | grep -e ANUM -e TXREGD
gives me all ANUMs and TXREGDs.
But I need ANUMs which has TXREGD only.
And I should know which ANUM has which TXREGD.
Ex:
ANUM=900
TXREGD=0
ANUM=890
TXREGD=1
Thanks
There's no need for cat.
grep -e ANUM -e TXREGD tmp.file
Did you try the script I posted?
awk '
BEGIN { RS=""}
/TXREGD/ ' "$FILE" |
awk '/ANUM/ { print } /TXREGD/ { print; print ""}'