0
我在文本文件中有一个令牌列表,并希望使用grep从包含这些令牌的第二个文本文件中获取行,但似乎无法使用grep访问shell变量:在grep中使用Shell变量
for n in `cat ./pos/1.txt`
do
cat dictionary.txt | grep "$n"
done
我试过$ N “$ N”,$ {N}, “$ {N}”,^ $ {N},和 “^ $ {N}” 他们似乎都不上班。
感谢
你为什么不试试这个? 'grep“$ n”dictionary.txt' –
我想你的整件事情会更好地写成'grep -f pos/1.txt dictionary.txt'。 –
这个问题在Unix + Linux上交叉发布:http://unix.stackexchange.com/questions/233714/using-a-shell-variable-with-grep – John1024