So when I run this in Fedora I'm seeing this:
$ ls hmm_data/indivA12_AATAAG/refs/par1/
2R-orths.alleles 2R-ref.alleles
$ ls hmm_data/indivA12_AATAAG/refs/par1/ | grep -F '-ref.alleles'
2R-ref.alleles
But when I run on Ubuntu (same data) I don't get any results from the grep:
$ ls hmm_data/indivA12_AATAAG/refs/par1/
2R-orths.alleles 2R-ref.alleles
$ ls hmm_data/indivA12_AATAAG/refs/par1/ | grep -F '-ref.alleles'
Any ideas what could be going on? How can I come up with something that will work the same on both systems?
is equivalent to:
(none of the characters between the apostrophes are shell metacharacters, so quoting them has no effect.)
This is in turn equivalent to:
by normal parsing of
-
prefixed options. The-e
option takes an argument, but-F
and-r
don't.Since you didn't specify any files to grep, the default behavior is to act on stdin... except that the
-r
option makes no sense so it defaults to searching.
(the current directory) recursively instead and ignores stdin. In some versions.You need to use the
--
"no more options" indicator before a regexp that starts with-
as inI tracked down the point where the behavior of
-r
with no file arguments changed. It was in version 2.11, released March 2, 2012. See the release announcement.The git commits which affected the behavior are this one and this one.
If you run
grep --version
on your two machines, I'm sure you'll find that one of them is on the wrong side of 2.11The leading
-
is the problem. To get same results add--
:From
man bash
:Check .bashrc if there are any aliases on your grep command which override it's behaviour. Maybe it is the issue. Also try grep without the "-F" param.