grep的含恩pression变量 [英] grep for expression containing variable

查看:124
本文介绍了grep的含恩pression变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要补充这个命令的的grep -CO'\\ B5 \\ B'$ INFILE 在bash脚本。问题是,不是5,我想在它的位置使用变量,所以我写的:

I want to add this command grep -co '\b5\b' $INFILE in a bash script. The problem is that instead of 5 i want to use a variable in its place so i write:

V=`grep -co '\b$L\b' $INFILE`

但是,由于$用于内部描述的grep行的末尾它不起作用。我怎样才能使它发挥作用?是否有$,使其使用变量的值,它的含义的bash转义序列?

but it does not work since the $ is used to describe internally the end of line in grep. How can i make it work? Is there an escape sequence for $ to make it use its bash meaning of the value of a variable?

推荐答案

使用而不是 允许扩展你的 $ L 的变量。

Use " instead of ' to allow expansion of your $L variable.

这篇关于grep的含恩pression变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆