Hi all,
I have a requirement where the variable name starts with $, like
$Amd=/home/student/test/
How to work wit it? can some one help me, am in gr8 confusion:confused:
Which shell, which language?
I don't think this is possible with sh/ksh/bash/awk/perl/php.
Hi.
Note that the $ is not listed.
There is a way that the look of your requirement can be done -- essentially as an indirect assignment:
#!/bin/bash -
# @(#) z1 Demonstrate indirect assignment.
echo
a=0
b=1
a=b
echo " first assignment a = $a, b = $b"
echo
$a=2
echo " second assignment a = $a, b = $b"
echo
eval $a=2
echo " eval assignment a = $a, b = $b"
exit
Producing:
% ./z1
first assignment a = b, b = 1
./z1: line 12: b=2: command not found
second assignment a = b, b = 1
eval assignment a = b, b = 2
However, in general, $ is used as the dereferencing operator in shells. In elementary perl, it must be used to identify scalar variables ... cheers, drl
I dint understand how ur solution could help me out in my requirment. If we have $ before any variable the flie throws an error message how to escape it....?????
dont post the same thing twice
go read the rules
so bottom line is you can't have a variable name starting with '$'???