Discussion: awk
Afficher un message
Vieux 22/08/2006, 19h53   #2
Xicheng Jia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: awk

AL wrote:
> Why in the following code?
>
> varA=2;
>
> strA="`cat /root/mytempdir/wordlist.txt | awk '{print $ 2}'`"
> strB="`cat /root/mytempdir/wordlist.txt | awk '{print $ $varA}'`"
>
> strA contains the second word of line 1
> and strB contains all line 1
> ???


shell variables within single-quotes are not interpolated. try
enclosing the awk statements with double quotes.

strB=`cat /root/mytempdir/wordlist.txt | awk "{print $ $varA}"`

--
XC

  Réponse avec citation
 
Page generated in 0,05453 seconds with 9 queries