Good Moring,
I am currently reading about awk in a manual and following the examples using the oratab file.
My system is SOLARIS 10
I think I am getting strange behavior judging by what the book says to do and what I am getting with my little program.
Here is my program:
grep -v [#] oratab | /usr/xpg4/bin/awk 'BEGIN { RS = ":" } ; /Y/ { print $1, $3 }'
sample from oratab: Before parsing.
#dlspfx:/oracle/product/10.2.0/db05_2:Y
#dlpayx:/oracle/product/10.2.0/db05_2:Y
dlqdbx:/oracle/product/10.2.0/db05_2:N
tundtimx:/oracle/product/11.2.0/dbhome_4:Y
EXPECTED OUTPUT:
dlspfx Y
dlpayx Y
tundtimx Y
But my actual is:
ACTUAL OUTPUT:
Y
Y
Y
It appears that something has shifted and I can�t figure out what is wrong with my syntax in the original statement.
grep -v [#] oratab | /usr/xpg4/bin/awk 'BEGIN { RS = ":" } ; /Y/ { print $1, $3 }'
I did the following print and the output is below it.
FIELD $0: suppose to return the entire string ex. tsaimx:/oracle/product/11.2.0/dbhome_3:Y
but doesn�t. It returns the correct information but in reverse order: field $3 then $1. It should be the other way around.
grep -v [#] oratab | /usr/xpg4/bin/awk 'BEGIN { RS = ":" } ; /Y/ { print $0 }'
Y
as10gr2
Y
cmf1
Y
cmf2
This should have printed out all 3 fields but doesn�t. Only field 1 and 3 are printed and they are also printed in reverse order.
grep -v [#] oratab | /usr/xpg4/bin/awk 'BEGIN { RS = ":" } ; /Y/ { print $1, $2, $3 }'
Y as10gr2
Y cmf1
Y cmf2
Y cmf9
This command prints the field that is NOT LISTED in the print command !!! It prints field number 1.
grep -v [#] oratab | /usr/xpg4/bin/awk 'BEGIN { RS = ":" } ; /Y/ { print $2, $3 }'
record: tsaimx:/oracle/product/11.2.0/dbhome_3:Y
cmf2
cmf9
dev101
tundaimx
tundatmx
tundcllx
Why isn�t my program working as expected?
Any help on this matter would be appreciated.
thanks in advance