Off topic:Help with awk statement in a shell script
0
0
Entering edit mode
3.6 years ago

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 • 566 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2356 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6