![]() |
Problem in assigning value to a variable in shell script.
Hi,
Why doesn't "var1=`echo $var2 | grep pattern`" work ? Please help me. |
It should. What does the command in between tickers (`) return? What ***exact*** line are you using in your script? I need to see it exactly as-is, to the last quote and punctuation character, please, copy/paste directly. Also, explain ***how*** it doesn't work. Is there an error? Is it just empty? How are you retrieving or using $var1? What's the contents of $var2?
|
It does normally work. Can you copy and paste testing it at the command prompt, including an echo "'$var2'" before the problem variable assignment so we can see exactly what you are doing?
|
Quote:
procinfo=`awk -F\\\t '/model name/{print $2}' /proc/cpuinfo` varDual=`echo $procinfo | grep Duo` |
Quote:
procinfo=`awk -F\\\t '/model name/{print $2}' /proc/cpuinfo` varDual=`echo $procinfo | grep Duo` |
What is the output of awk -F\\\t '/model name/{print $2}' /proc/cpuinfo on your system?
|
Quote:
|
So then what do you get after running:
Code:
echo "$varDual"Quote:
|
Quote:
|
| All times are GMT -5. The time now is 10:52 PM. |