This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Help with awk statement in a shell script

I have a file that contains the following line that is the input to a SYBASE query. where so.name = "tablename" I run this query in a shell script within a for loop. I am attempting to get all the column names in each table in a SYBASE ASE database. My for loop is something like this

 for tablename in `cat $TBLNAME.$DBNAM.out
do
  awk '$1=="where"{$4="\"$tablename\""}1' $CLMNSQL . tmp2 && mv tmp2 $CLMNSQL 
  get_column_names
done

the data in $TBLNAME.$DBNAM.out looks something like this

tbaccessfilter
 tbbillingrules
 tbconcurrentusers
 tbconfigaudit
 tbconfigname
 tbconfiguration
 tbcustomer
 tbcustomersdomtype
 tbcustomersshippingtype

My question is how do I relpace the "tablename" in the file $CLMNSQL with what is contained in the $tablename variable in my awk statement, because what I have there does not work? What would the sed command look like if i use sed instead?

awk

Hello terry.walters!

We believe that this post does not fit the main topic of this site.

This does not look like a bionformatics question. Please let us know if it is, and explain how.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

No it does not, so you can delete me from you site, as I came to this site when doing a Google search for my problem.

0 answers

No answers yet.

Log in to answer this question.