I read a little online but couldn't find an answer. Suppose I have this line (and some other):
olga gell-er tel-aviv 56 43
I want to use grep to look for a name in a file (let's say it only contains this line at the moment). The thing is I want to look for the exact string, including the "-". so if I search for olga gell , it won't find it in the file.
So far I've tried ($2 $3 are the string from the command line, $1 is the name of the file)
grep -iwc ^"$2 $3" $1
but this options also finds me olga gell, which I don't want. so how do I fix this?
My command line looks something like this:
change_team.bash players olga gell Real new2
change_team.bash is the name of the script. players is the file. "olga gell" is the name I'm searching for, and the rest is irrelevant at the moment.
以下解决了您的问题:
./scriptName.sh test olga gell[\w-]
如果名称后总是有空格,则只需将空格作为样式的一部分即可。
grep -iwc ^"$2 $3 " $1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.