I am trying a FOR loop in Linux Shell script to generate a condition to be passed on to a SQL query within the shell script. The following is the portion that is giving error:
> condition=${primarykey//,/ }
> echo $condition
cond1 cond2
> temp=""
> for i in $condition
> do
> $temp="${temp}c.${i}\=s.${i} AND "
> done
I am looking for the following expression to be generated:
> echo $temp
c.cond1=s.cond1 AND c.cond2=s.cond2
However, I get the following error:
./script.sh: line 28: =c.cond1\=s.cond1 AND : command not found
./script.sh: line 28: =c.cond2\=s.cond2 AND : command not found
Could someone help me with the right way to get this expression?
The $
implies substitution. As in, take the contents of the variable and substitute it into the command line at that point. If you want to assign then you must not substitute.
TL;DR: Remove the dollar sign to the left of the equals sign.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다