echoing '&' from a script ...

maccatalan

Registered
Hello everybody.

I have little problem with ksh ...

I am trying to execute this line into a shell script :

nbligne=`wc -l ${fichier}.tmp | awk '{print $1}'`

The problem comes from the '$1' ... I don't want the shell to replace it by it's value but to send it as it ("$1" and not "hello" if $1=hello) in order to get awk working properly.

Do you know, please, how to proceed ?

Thank you,
Pierre.

NB: I tried writting
nbligne=`wc -l ${fichier}.tmp | awk '{print \$1}'`
but it changes nothing ... :(
 
Interesting, I can't get that line _not_ to work, in tcsh, zsh and bash. I don't have ksh handy. Does the script need to be in ksh, or would another shell do?
 
Indeed the script needs to be in ksh.
The command is ok since it works in the shell when I type it directly.

I solved the problem by writing

nblignes=`wc -l < ${fichier}.tmp`

what produces the same effect.
But the question remains.

NB: when we write :
echo "$$A"
or
echo "\$A"
then the $ is echoed normally : "$A".
However when I try to put this into the `command`then I get an error from awk which sees the '\' ... :(

Thank you,
Pierre.

NB: since now the script can work normally it is no more important, it is just curiosity ;)

NB: you can download kornshell (ksh) from the web for mac os x. ;)
 
Back
Top