grep 和命令行变量替换

grep 和命令行变量替换

在以下命令序列中,

 $ grep -E '^.{11,22}John' emplist 
 Operations John Thompson  PARTHawks        Cher           
 Sales      John Jacobs    FULLHawks        Davinder Singh 
 Finance    Dean Johnson   FULLVegans       Sandeep Jain   
 $ Name=John
 $ grep -E '^.{11,22}$Name' emplist 
 $ 

我想要的输出

grep -E '^.{11,22}$Name' emplist

与输出相同

grep -E '^.{11,22}John' emplist 

答案1

Name=John
grep -E "^.{11,22}$Name" emplist

相关内容