1

I am facing some problems in replacing the value of a variable in a html tag in a unix box. Here are the details. Please help me in finding a solution.

#!/bin/ksh

count=5

line="<td>$count</td>"

echo "$line"

I am expecting the output to be <td>5</td> but I am getting the output as <td>$count</td>.

I tried a lot to solve this but couldn't :(

  • Your likely problem is that ksh doesn't do variable expansion the same way bash does. – Shadur Sep 23 '11 at 9:43
  • 1
    The script you posted does output <td>5</td>. Did you copy-paste the right script? How are you running it? – Gilles 'SO- stop being evil' Sep 23 '11 at 21:55
1

I'm not an expert on ksh but according to the documentation, the following should work (if slightly clunky):

echo -n "<td>" 
echo -n ${count} 
echo "</td>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.