I have a file which has entries like this
dat1,dat2,dat3
datm,datn,dato
#dat1,dat3,data
dat2,datp,datq
daty,dat1,datb
The requirement which I have is to find the 2nd field when the first field is a particular value.
Assume the value I am checking is dat1 and the code should return dat2. If I use grep,the first, 3rd and 5th record will be returned. I can use awk to get the first field
and then remove the record with # and then get the second record, but I am unable to write the code for it. Could any one help me please.
Thanks,
dbadmin
dat1,dat2,dat3
datm,datn,dato
#dat1,dat3,data
dat2,datp,datq
daty,dat1,datb
The requirement which I have is to find the 2nd field when the first field is a particular value.
Assume the value I am checking is dat1 and the code should return dat2. If I use grep,the first, 3rd and 5th record will be returned. I can use awk to get the first field
and then remove the record with # and then get the second record, but I am unable to write the code for it. Could any one help me please.
Thanks,
dbadmin