sql - sed command not working properly -


i executing

/bin/sed -i '/^$/d' $primary_k     value=`/bin/cat $primary_k`     echo "$value"     pk=sys     new="$pk$value" echo "new primary key constraint $s- $new"     /bin/sed "s/$value/$new/g" ../../../partitioningutility/sql/table7.sql >  ../../../partitioningutility/sql/exe.sql 

last line /bin/sed "s/$value/$new/g" not replacing value.

when try hardcoded values, it's working. e.g. tried

/bin/sed "s/mayur/sawant/g"  

its working. suggestions.

change script to:

awk -v s="$s" ' nr==fnr {     if (nf) {         value = $1         print value | "cat>&2"          pk = "sys"         new = pk value          printf "new primary key constraint %s- %s\n", s, new | "cat>&2"     }     next } {     gsub(value,new)     print } ' "$primary_k" ../../../partitioningutility/sql/table7.sql >  ../../../partitioningutility/sql/exe.sql 

to fix current bug , pending performance, maintenance, reliability, etc. issues.

to put numbers before fields on each row simply:

awk '{ (i=1; i<=nf; i++) printf "%s%s.%s",(i==1?"":ofs),i,$i; print "" }' 

if doesn't answer question in comments, ask new question sample input , expected output.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -