Hacker News new | ask | show | jobs
by nameiscubanpete 2966 days ago
Under what shell? If this works as described, then it's broke.
1 comments

This is bash (CentOS 6x).. will have to check exact version whilst at next available computer..
Correction, this was done on CentOS 7.3.x (not CentOS 6 as I had incorrectly first noted), and the following versions of bash and grep:

"GNU bash, version 4.2.46(1)-release (x86_64-redhat-linux-gnu)"

"grep (GNU grep) 2.20"

So where $data is a newline delimited list of items/patterns:

  grep "${data}" 
..will indeed match each item/pattern individually and grep over each, eg, just as grep -f does against a file with a list of patterns. It doesn't work without the double quotes, and putting the echo in front was obvious derp in hindsight. See my comment where I replied to uraza and demonstrated this.