read column values one after another

hi,

Can some one help me how to retrieve column values row by row

My requirement is like below :

I have a text file having comma seperated values of these records .
OName OType SrcDB Sschema targetdb TSchema Load Dataype processY/N
aa Table a e i m Y db2 y
aa index b c d e N sql N

Now i have to open read the file record wise,

check if last column processy/n is yes,
then check the datatype

basically i want to get a nth column values one after another not as a single result.

Some one help me pls it would be of great help
thanks much

To keep the forums high quality for all users, please take the time to format your posts correctly.

  1. Use Code Tags when you post any code or data samples so others can easily read your code.
    You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags and by hand.)
  2. Avoid adding color or different fonts and font size to your posts.
    Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.
  3. Be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
Reply With Quote

Didn't get your req fully..
but you can read last column by awk

awk '{if($NF="Y"){print "data type="$(NF-1)}else{print "whatever"}}' filename

My requirement is like this.
I have a text file having comma seperated values of these records .
OName OType SrcDB Sschema targetdb TSchema Load Dataype processY/N
aa Table a e i m Y db2 y
aa index b c d e N sql N

Now i have to open read the file record wise,

check if last column processy/n is yes,
then check the datatype
if it is db2
then connect to db2
check the otype column value
based on type of object i have to execute the below operations.

so my shell script should have all the possible commands present. my script should check type of the object, replace varaiables with values picked from record and execute the shell script.

ex create <SrcDB> <targetdb> <Sschema> <TSchema> <OName>

and then send the output to log and error files.

I am new to unix and not able to proceed any where.
Please help me.

---------- Post updated at 12:30 AM ---------- Previous update was at 12:27 AM ----------

thanks so much for your reply. i have sent my complete requirement.

pls help me to resolve this issue

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

Continue here:

The UNIX and Linux Forums.