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
|