On 06/11/08 17:37, Nikos Alexandris wrote:
On Thu, 2008-11-06 at 11:18 +0100, Paolo Craveri wrote:ciao to allpay attention to spaces between column name in v.db.renamecol: no spaces before and after comma. Command substitution: backticks → $(....) not substantial differences; the second form is easier to read and write; it is also nestable (we are all used to ` ` form, but $() is better (IMHO)) This should work (probably): ================================ db.columns test key_column="cat" suffix="_tmp" for column in `db.columns test`; do if [ "$column" != "$key_column" ]; then tempcolumn=$(echo $column | awk '{print tolower($1)}') tempcolumn=$tempcolumn$suffix v.db.renamecol map=test layer=1 column=$column,$tempcolumn lower_column=$(echo $tempcolumn $suffix| awk '{print substr($1,1,length($1)-length($2))}') v.db.renamecol map=test layer=1 column=$tempcolumn,$lower_column fi done db.columns test =================== ciaoCiao Paolo & Moritz! Thank you for your assistance. @Moritz: I tried it but still not clean. # cat caps_2_lower_moritzx.sh -n 1 #!/bin/sh -x 2 3 key_column="cat" 4 suffix="\_tmp" 5 for column in `db.columns test`; do 6 if [ "$column" != "$key_column" ]; then 7 tempcolumn=`echo $column | awk '{print tolower($1)}'` 8 tempcolumn="$tempcolumn""\_tmp" 9 echo $tempcolumn 10 v.db.renamecol map=befliegung_copy column= $column,$tempcolumn 11 lower_column=`echo $tempcolumn $suffix | awk '{print 12 substr($1,1,length($1)-length($2))}'`
[...]
# output block_id\_tmp
I think this is because of the quotes: tempcolumn="$tempcolumn""\_tmp"But actually, trying out your entire original script, I don't see where the problem is. The attached version seems to work perfectly for me (just slightly simplified from your original version):
What exactly did not work when you tried this ? Moritz
change_case.sh
Description: application/shellscript
_______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
